/// Package import.
import 'dart:async';
import 'dart:convert';
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
// ignore: directives_ordering
import 'package:google_generative_ai/google_generative_ai.dart';

/// Chart import.
import 'package:syncfusion_flutter_charts/charts.dart';

/// Local import.
import '../../../../../model/sample_view.dart';
import '../../helper/ai_pop_up_api_key.dart';

///Renders default Line series Chart.
class StockForecastingSample extends SampleView {
  const StockForecastingSample(Key key) : super(key: key);

  @override
  _StockForecastingSampleState createState() => _StockForecastingSampleState();
}

class _StockForecastingSampleState extends SampleViewState
    with SingleTickerProviderStateMixin {
  _StockForecastingSampleState();
  final String msftStockSource =
      '6/28/2024\t453.07\t455.38\t446.41\t446.95\t28,362,270\r\n6/27/2024\t452.18\t456.17\t451.77\t452.85\t14,806,320\r\n6/26/2024\t449\t453.6\t448.19\t452.16\t16,507,029\r\n6/25/2024\t448.25\t451.42\t446.75\t450.95\t16,747,529\r\n6/24/2024\t449.8\t452.75\t446.41\t447.67\t15,913,720\r\n6/21/2024\t447.38\t450.58\t446.51\t449.78\t34,486,168\r\n6/20/2024\t446.3\t446.53\t441.27\t445.7\t19,877,381\r\n6/18/2024\t449.71\t450.14\t444.89\t446.34\t17,112,500\r\n6/17/2024\t442.59\t450.94\t440.72\t448.37\t20,790,029\r\n6/14/2024\t438.28\t443.14\t436.72\t442.57\t13,581,990\r\n6/13/2024\t440.85\t443.39\t439.37\t441.58\t15,960,570\r\n6/12/2024\t435.32\t443.4\t433.25\t441.06\t22,366,230\r\n6/11/2024\t425.48\t432.82\t425.25\t432.68\t14,551,100\r\n6/10/2024\t424.7\t428.08\t423.89\t427.87\t14,003,030\r\n6/7/2024\t426.2\t426.28\t423\t423.85\t13,621,650\r\n6/6/2024\t424.01\t425.31\t420.58\t424.52\t14,861,250\r\n6/5/2024\t417.81\t424.08\t416.3\t424.01\t16,988,039\r\n6/4/2024\t412.43\t416.44\t409.68\t416.07\t14,348,920\r\n6/3/2024\t415.53\t416.43\t408.92\t413.52\t17,484,680\r\n5/31/2024\t416.75\t416.75\t404.51\t415.13\t47,995,246\r\n5/30/2024\t424.3\t424.3\t414.24\t414.67\t28,424,850\r\n5/29/2024\t425.69\t430.94\t425.69\t429.17\t15,517,130\r\n5/28/2024\t429.63\t430.82\t426.6\t430.32\t15,718,020\r\n5/24/2024\t427.19\t431.06\t424.41\t430.16\t11,855,290\r\n5/23/2024\t432.97\t433.6\t425.42\t427\t17,211,689\r\n5/22/2024\t430.09\t432.41\t427.13\t430.52\t18,073,699\r\n5/21/2024\t426.83\t432.97\t424.85\t429.04\t21,453,260\r\n5/20/2024\t420.21\t426.77\t419.99\t425.34\t16,272,140\r\n5/17/2024\t422.54\t422.92\t418.03\t420.21\t15,352,240\r\n5/16/2024\t421.8\t425.42\t420.35\t420.99\t17,530,051\r\n5/15/2024\t417.9\t423.81\t417.27\t423.08\t22,239,529\r\n5/14/2024\t412.02\t417.49\t411.55\t416.56\t15,109,310\r\n5/13/2024\t418.01\t418.35\t410.82\t413.72\t15,440,230\r\n5/10/2024\t412.94\t415.38\t411.8\t414.74\t13,402,280\r\n5/9/2024\t410.57\t412.72\t409.1\t412.32\t14,689,730\r\n5/8/2024\t408.17\t412.23\t406.71\t410.54\t11,792,310\r\n5/7/2024\t414.66\t414.67\t409.09\t409.34\t20,018,230\r\n5/6/2024\t408.76\t413.93\t406.37\t413.54\t16,996,641\r\n5/3/2024\t402.28\t407.15\t401.86\t406.66\t17,446,721\r\n5/2/2024\t397.66\t399.93\t394.65\t397.84\t17,709,359\r\n5/1/2024\t392.61\t401.72\t390.31\t394.94\t23,562,480\r\n4/30/2024\t401.49\t402.16\t389.17\t389.33\t28,781,369\r\n4/29/2024\t405.25\t406.32\t399.19\t402.25\t19,582,090\r\n4/26/2024\t412.17\t413\t405.76\t406.32\t29,694,650\r\n4/25/2024\t394.03\t399.89\t388.03\t399.04\t40,586,449\r\n4/24/2024\t409.56\t412.47\t406.78\t409.06\t15,065,330\r\n4/23/2024\t404.24\t408.2\t403.06\t407.57\t15,734,500\r\n4/22/2024\t400.08\t402.85\t395.75\t400.96\t20,286,881\r\n4/19/2024\t404.03\t405.48\t397.77\t399.12\t30,565,789\r\n4/18/2024\t410.63\t411.89\t403.95\t404.27\t21,029,920\r\n4/17/2024\t417.25\t418.88\t410.33\t411.84\t15,855,490\r\n4/16/2024\t414.57\t418.4\t413.73\t414.58\t16,765,619\r\n4/15/2024\t426.6\t426.82\t413.43\t413.64\t20,273,539\r\n4/12/2024\t424.05\t425.18\t419.77\t421.9\t19,253,750\r\n4/11/2024\t425.82\t429.37\t422.36\t427.93\t17,966,420\r\n4/10/2024\t422.19\t424.03\t419.7\t423.26\t16,216,580\r\n4/9/2024\t426.44\t427.74\t421.62\t426.28\t12,512,290\r\n4/8/2024\t425.17\t427.28\t423.3\t424.59\t14,272,390\r\n4/5/2024\t420.01\t426.51\t418.32\t425.52\t16,554,760\r\n4/4/2024\t424.99\t428.67\t417.57\t417.88\t19,370,881\r\n4/3/2024\t419.73\t423.26\t419.09\t420.45\t16,502,260\r\n4/2/2024\t420.11\t422.38\t417.84\t421.44\t17,911,990\r\n4/1/2024\t423.95\t427.89\t422.22\t424.57\t16,315,960\r\n3/28/2024\t420.96\t421.87\t419.12\t420.72\t21,871,160\r\n3/27/2024\t424.44\t424.45\t419.01\t421.43\t16,704,980\r\n3/26/2024\t425.61\t425.99\t421.35\t421.65\t16,725,650\r\n3/25/2024\t425.24\t427.41\t421.61\t422.86\t18,060,449\r\n3/22/2024\t429.7\t429.86\t426.07\t428.74\t17,648,471\r\n3/21/2024\t429.83\t430.82\t427.16\t429.37\t21,296,221\r\n3/20/2024\t422\t425.96\t420.66\t425.23\t17,860,090\r\n3/19/2024\t417.83\t421.67\t415.55\t421.41\t19,837,920\r\n3/18/2024\t414.25\t420.73\t413.78\t417.32\t20,105,980\r\n3/15/2024\t419.29\t422.6\t412.79\t416.42\t45,079,898\r\n3/14/2024\t420.24\t427.82\t417.99\t425.22\t34,157,301\r\n3/13/2024\t418.1\t418.18\t411.45\t415.1\t17,115,930\r\n3/12/2024\t407.62\t415.57\t406.79\t415.28\t22,457,000\r\n3/11/2024\t403.76\t405.68\t401.26\t404.52\t16,120,750\r\n3/8/2024\t407.96\t410.42\t404.33\t406.22\t18,002,189\r\n3/7/2024\t406.12\t409.78\t402.24\t409.14\t18,718,480\r\n3/6/2024\t402.97\t405.16\t398.39\t402.09\t22,344,150\r\n3/5/2024\t413.96\t414.25\t400.64\t402.65\t26,919,180\r\n3/4/2024\t413.44\t417.35\t412.32\t414.92\t17,595,961\r\n3/1/2024\t411.27\t415.87\t410.88\t415.5\t17,823,449\r\n2/29/2024\t408.64\t414.2\t405.92\t413.64\t31,947,260\r\n2/28/2024\t408.18\t409.3\t405.32\t407.72\t13,183,130\r\n2/27/2024\t407.99\t408.32\t403.85\t407.48\t14,835,830\r\n2/26/2024\t411.46\t412.16\t407.36\t407.54\t16,193,510\r\n2/23/2024\t415.67\t415.86\t408.97\t410.34\t16,295,880\r\n2/22/2024\t410.19\t412.83\t408.57\t411.65\t27,009,869\r\n2/21/2024\t400.17\t402.29\t397.22\t402.18\t18,631,070\r\n2/20/2024\t403.24\t404.49\t398.01\t402.79\t24,307,920\r\n2/16/2024\t407.96\t408.29\t403.44\t404.06\t22,296,500\r\n2/15/2024\t408.14\t409.13\t404.29\t406.56\t21,825,529\r\n2/14/2024\t408.07\t409.84\t404.57\t409.49\t20,401,189\r\n2/13/2024\t404.94\t410.07\t403.39\t406.32\t27,824,939\r\n2/12/2024\t420.56\t420.74\t414.75\t415.26\t21,202,920\r\n2/9/2024\t415.25\t420.82\t415.09\t420.55\t22,032,840\r\n2/8/2024\t414.05\t415.56\t412.53\t414.11\t21,225,260\r\n2/7/2024\t407.44\t414.3\t407.4\t414.05\t22,340,529\r\n2/6/2024\t405.88\t407.97\t402.91\t405.49\t18,382,619\r\n2/5/2024\t409.9\t411.16\t403.99\t405.65\t25,352,289\r\n2/2/2024\t403.81\t412.65\t403.56\t411.22\t28,256,670\r\n2/1/2024\t401.83\t408\t401.8\t403.78\t30,657,730\r\n1/31/2024\t406.96\t415.32\t397.21\t397.58\t47,871,102\r\n1/30/2024\t412.26\t413.05\t406.45\t408.59\t33,477,609\r\n1/29/2024\t406.06\t409.98\t404.33\t409.72\t24,510,240\r\n1/26/2024\t404.37\t406.17\t402.43\t403.93\t17,803,270\r\n1/25/2024\t404.32\t407.01\t402.53\t404.87\t21,021,160\r\n1/24/2024\t401.54\t405.63\t400.45\t402.56\t24,866,949\r\n1/23/2024\t395.75\t399.38\t393.93\t398.9\t20,525,881\r\n1/22/2024\t400.02\t400.62\t393.59\t396.51\t27,016,900\r\n1/19/2024\t395.76\t398.67\t393.5\t398.67\t29,331,141\r\n1/18/2024\t391.72\t393.99\t390.12\t393.87\t23,392,070\r\n1/17/2024\t387.98\t390.11\t384.81\t389.47\t22,234,109\r\n1/16/2024\t393.66\t394.03\t387.62\t390.27\t27,202,270\r\n1/12/2024\t385.49\t388.68\t384.65\t388.47\t21,661,150\r\n1/11/2024\t386\t390.68\t380.38\t384.63\t27,850,850\r\n1/10/2024\t376.37\t384.17\t376.32\t382.77\t25,514,250\r\n1/9/2024\t372.01\t375.99\t371.19\t375.79\t20,829,949\r\n1/8/2024\t369.3\t375.2\t369.01\t374.69\t23,133,971\r\n1/5/2024\t368.97\t372.06\t366.5\t367.75\t21,004,580\r\n1/4/2024\t370.67\t373.1\t367.17\t367.94\t20,901,500\r\n1/3/2024\t369.01\t373.26\t368.51\t370.6\t23,083,471\r\n1/2/2024\t373.86\t375.9\t366.77\t370.87\t25,258,631\r\n12/29/2023\t376\t377.16\t373.48\t376.04\t18,730,840\r\n12/28/2023\t375.37\t376.46\t374.16\t375.28\t14,327,010\r\n12/27/2023\t373.69\t375.06\t372.81\t374.07\t14,905,410\r\n12/26/2023\t375\t376.94\t373.5\t374.66\t12,673,050\r\n12/22/2023\t373.68\t375.18\t372.71\t374.58\t17,107,480\r\n12/21/2023\t372.56\t374.41\t370.04\t373.54\t17,708,010\r\n12/20/2023\t375\t376.03\t370.53\t370.62\t26,316,650\r\n12/19/2023\t371.49\t373.26\t369.84\t373.26\t20,603,660\r\n12/18/2023\t369.45\t373\t368.68\t372.65\t21,802,881\r\n12/15/2023\t366.85\t372.4\t366.28\t370.73\t78,502,320\r\n12/14/2023\t373.31\t373.76\t364.13\t365.93\t43,277,461\r\n12/13/2023\t376.02\t377.64\t370.77\t374.37\t30,955,529\r\n12/12/2023\t370.85\t374.42\t370.46\t374.38\t24,838,250\r\n12/11/2023\t368.48\t371.6\t366.1\t371.3\t27,708,760\r\n12/8/2023\t369.2\t374.46\t368.23\t374.23\t20,154,369\r\n12/7/2023\t368.23\t371.45\t366.32\t370.95\t23,118,859\r\n12/6/2023\t373.54\t374.18\t368.03\t368.8\t21,182,070\r\n12/5/2023\t366.45\t373.08\t365.62\t372.52\t23,065,039\r\n12/4/2023\t369.1\t369.52\t362.9\t369.14\t32,063,311\r\n12/1/2023\t376.76\t378.16\t371.31\t374.51\t33,040,469\r\n11/30/2023\t378.49\t380.09\t375.47\t378.91\t30,554,420\r\n11/29/2023\t383.76\t384.3\t377.44\t378.85\t28,963,400\r\n11/28/2023\t378.35\t383\t378.16\t382.7\t20,453,109\r\n11/27/2023\t376.78\t380.64\t376.2\t378.61\t22,179,230\r\n11/24/2023\t377.33\t377.97\t375.14\t377.43\t10,176,650\r\n11/22/2023\t378\t379.79\t374.97\t377.85\t23,361,180\r\n11/21/2023\t375.67\t376.22\t371.12\t373.07\t28,423,150\r\n11/20/2023\t371.22\t378.87\t371\t377.44\t52,528,961\r\n11/17/2023\t373.61\t374.37\t367\t369.85\t40,325,367\r\n11/16/2023\t370.96\t376.35\t370.18\t376.17\t27,182,320\r\n11/15/2023\t371.28\t373.13\t367.11\t369.67\t26,860,100\r\n11/14/2023\t371.01\t371.95\t367.35\t370.27\t27,683,859\r\n11/13/2023\t368.22\t368.47\t365.9\t366.68\t19,986,510\r\n11/10/2023\t361.49\t370.1\t361.07\t369.67\t28,065,160\r\n11/9/2023\t362.3\t364.79\t360.36\t360.69\t24,847,330\r\n11/8/2023\t361.68\t363.87\t360.55\t363.2\t26,767,830\r\n11/7/2023\t359.4\t362.46\t357.63\t360.53\t25,833,930\r\n11/6/2023\t353.45\t357.54\t353.35\t356.53\t23,828,301\r\n11/3/2023\t349.63\t354.39\t347.33\t352.8\t23,637,670\r\n11/2/2023\t347.24\t348.83\t344.77\t348.32\t24,348,070\r\n11/1/2023\t339.79\t347.42\t339.65\t346.07\t28,158,820\r\n10/31/2023\t338.85\t339\t334.69\t338.11\t20,265,279\r\n10/30/2023\t333.41\t339.45\t331.83\t337.31\t22,828,080\r\n10/27/2023\t330.43\t336.72\t328.4\t329.81\t29,856,520\r\n10/26/2023\t340.54\t341.63\t326.94\t327.89\t37,828,539\r\n10/25/2023\t345.02\t346.2\t337.62\t340.67\t55,053,832\r\n10/24/2023\t331.3\t331.84\t327.6\t330.53\t31,153,570\r\n10/23/2023\t325.47\t332.73\t324.39\t329.32\t24,374,750\r\n10/20/2023\t331.72\t331.92\t325.45\t326.67\t25,027,721\r\n10/19/2023\t332.15\t336.88\t330.91\t331.32\t25,052,070\r\n10/18/2023\t332.49\t335.59\t328.3\t330.11\t23,153,600\r\n10/17/2023\t329.59\t333.46\t327.41\t332.06\t18,338,520\r\n10/16/2023\t331.05\t336.14\t330.6\t332.64\t22,158,051\r\n10/13/2023\t332.38\t333.83\t326.36\t327.73\t21,085,699\r\n10/12/2023\t330.57\t333.63\t328.72\t331.16\t19,313,100\r\n10/11/2023\t331.21\t332.82\t329.14\t332.42\t20,063,250\r\n10/10/2023\t330.96\t331.1\t327.67\t328.39\t20,557,090\r\n10/9/2023\t324.75\t330.3\t323.18\t329.82\t19,891,180\r\n10/6/2023\t316.55\t329.19\t316.3\t327.26\t25,673,631\r\n10/5/2023\t319.09\t319.98\t314.9\t319.36\t16,965,631\r\n10/4/2023\t314.03\t320.04\t314\t318.96\t20,720,141\r\n10/3/2023\t320.83\t321.39\t311.22\t313.39\t21,033,490\r\n10/2/2023\t316.28\t321.89\t315.18\t321.8\t20,570,010\r\n9/29/2023\t317.75\t319.47\t314.98\t315.75\t24,147,301\r\n9/28/2023\t310.99\t315.48\t309.45\t313.64\t19,683,561\r\n9/27/2023\t312.3\t314.3\t309.69\t312.79\t19,410,080\r\n9/26/2023\t315.13\t315.88\t310.02\t312.14\t26,297,570\r\n9/25/2023\t316.59\t317.67\t315\t317.54\t17,835,961\r\n9/22/2023\t321.32\t321.45\t316.15\t317.01\t21,447,891\r\n9/21/2023\t319.26\t325.35\t315\t319.53\t35,560,359\r\n9/20/2023\t329.51\t329.59\t320.51\t320.77\t21,436,529\r\n9/19/2023\t326.17\t329.39\t324.51\t328.65\t16,514,490\r\n9/18/2023\t327.8\t330.4\t326.36\t329.06\t16,834,211\r\n9/15/2023\t336.92\t337.4\t329.65\t330.22\t37,679,793\r\n9/14/2023\t339.15\t340.86\t336.57\t338.7\t20,267,051\r\n9/13/2023\t331.31\t336.85\t331.17\t336.06\t16,544,410\r\n9/12/2023\t335.82\t336.79\t331.48\t331.77\t17,565,480\r\n9/11/2023\t337.24\t338.42\t335.43\t337.94\t16,583,320\r\n9/8/2023\t330.09\t336.16\t329.46\t334.27\t19,548,170\r\n9/7/2023\t331.29\t333.08\t329.03\t329.91\t18,381,000\r\n9/6/2023\t333.38\t334.46\t330.18\t332.88\t17,535,770\r\n9/5/2023\t329\t334.85\t328.66\t333.55\t18,553,859\r\n9/1/2023\t331.31\t331.99\t326.78\t328.66\t14,942,020\r\n8/31/2023\t329.2\t330.91\t326.78\t327.76\t26,410,949\r\n8/30/2023\t328.67\t329.81\t326.45\t328.79\t15,222,110\r\n8/29/2023\t321.88\t328.98\t321.88\t328.41\t19,284,590\r\n8/28/2023\t325.66\t326.15\t321.72\t323.7\t14,808,480\r\n8/25/2023\t321.47\t325.36\t318.8\t322.98\t21,684,100\r\n8/24/2023\t332.85\t332.98\t319.96\t319.97\t23,281,430\r\n8/23/2023\t323.82\t329.2\t323.46\t327\t21,166,381\r\n8/22/2023\t325.5\t326.08\t321.46\t322.46\t16,102,020\r\n8/21/2023\t317.93\t322.77\t317.04\t321.88\t24,039,961\r\n8/18/2023\t314.49\t318.38\t311.55\t316.48\t24,755,010\r\n8/17/2023\t320.54\t321.87\t316.21\t316.88\t21,257,160\r\n8/16/2023\t320.8\t324.42\t319.8\t320.4\t20,698,859\r\n8/15/2023\t323\t325.09\t320.9\t321.86\t16,966,289\r\n8/14/2023\t321.39\t324.06\t320.08\t324.04\t18,836,141\r\n8/11/2023\t320.26\t322.41\t319.21\t321.01\t24,355,490\r\n8/10/2023\t326.02\t328.26\t321.18\t322.93\t20,113,730\r\n8/9/2023\t326.47\t327.11\t321.05\t322.23\t22,373,270\r\n8/8/2023\t326.96\t328.75\t323\t326.05\t22,327,570\r\n8/7/2023\t328.37\t331.11\t327.52\t330.11\t17,741,529\r\n8/4/2023\t331.88\t335.14\t327.24\t327.78\t23,741,480\r\n8/3/2023\t326\t329.88\t325.95\t326.66\t18,360,350\r\n8/2/2023\t333.63\t333.63\t326.36\t327.5\t27,761,260\r\n8/1/2023\t335.19\t338.54\t333.7\t336.34\t18,381,250\r\n7/31/2023\t336.92\t337.7\t333.36\t335.92\t25,446,020\r\n7/28/2023\t333.67\t340.01\t333.17\t338.37\t28,484,869\r\n7/27/2023\t340.48\t341.33\t329.05\t330.72\t39,635,262\r\n7/26/2023\t341.44\t344.67\t333.11\t337.77\t58,383,699\r\n7/25/2023\t347.11\t351.89\t345.07\t350.98\t41,637,738\r\n7/24/2023\t345.85\t346.92\t342.31\t345.11\t26,719,211\r\n7/21/2023\t349.15\t350.3\t339.83\t343.77\t69,405,375\r\n7/20/2023\t353.57\t357.97\t345.37\t346.87\t33,778,398\r\n7/19/2023\t361.75\t362.46\t352.44\t355.08\t39,732,898\r\n7/18/2023\t345.83\t366.78\t342.17\t359.49\t64,872,711\r\n7/17/2023\t345.68\t346.99\t342.2\t345.73\t20,363,930\r\n7/14/2023\t347.59\t351.43\t344.31\t345.24\t28,352,730\r\n7/13/2023\t339.56\t343.74\t339.02\t342.66\t20,567,160\r\n7/12/2023\t336.6\t341.65\t335.67\t337.2\t29,995,260\r\n7/11/2023\t331.06\t332.86\t327\t332.47\t26,698,221\r\n7/10/2023\t334.6\t335.23\t327.59\t331.83\t32,791,449\r\n7/7/2023\t339.32\t341.79\t337\t337.22\t21,214,820\r\n7/6/2023\t337.3\t342.99\t335.5\t341.27\t28,195,529\r\n7/5/2023\t335.09\t341.65\t334.73\t338.15\t18,172,381\r\n7/3/2023\t339.19\t340.9\t336.57\t337.99\t12,484,240\r\n6/30/2023\t337.75\t342.73\t337.2\t340.54\t26,832,760\r\n6/29/2023\t334.71\t336.11\t332.62\t335.05\t16,997,039\r\n6/28/2023\t334.66\t337.98\t333.81\t335.85\t20,259,520\r\n';

  final String googleStackSource =
      '6/28/2024\t184.32\t185.13\t181.96\t182.15\t29,156,641\r\n6/27/2024\t184.18\t186.05\t184.02\t185.41\t18,848,881\r\n6/26/2024\t182.63\t184.51\t182.48\t183.88\t19,838,971\r\n6/25/2024\t179.62\t184.29\t179.42\t184.03\t23,235,590\r\n6/24/2024\t180.16\t180.89\t178.67\t179.22\t18,298,010\r\n6/21/2024\t177\t180.85\t176.61\t179.63\t58,582,738\r\n6/20/2024\t175.37\t177.29\t174.99\t176.3\t20,160,090\r\n6/18/2024\t177.14\t177.39\t174.1\t175.09\t21,869,859\r\n6/17/2024\t175.46\t178.36\t174.81\t177.24\t19,618,500\r\n6/14/2024\t174.22\t177.06\t174.15\t176.79\t18,063,561\r\n6/13/2024\t176.11\t176.74\t174.88\t175.16\t20,913,301\r\n6/12/2024\t178.25\t180.41\t176.11\t177.79\t27,864,740\r\n6/11/2024\t176.22\t176.84\t173.77\t176.62\t21,540,580\r\n6/10/2024\t174.97\t177.06\t172.76\t175.01\t23,779,221\r\n6/7/2024\t177.05\t177.87\t174.3\t174.46\t19,661,400\r\n6/6/2024\t175.9\t177.15\t175.75\t176.73\t23,251,010\r\n6/5/2024\t175.2\t176.65\t173.93\t175.41\t22,068,520\r\n6/4/2024\t173.28\t173.85\t171.89\t173.79\t26,879,600\r\n6/3/2024\t172.54\t174.53\t171.16\t173.17\t27,459,119\r\n5/31/2024\t171.86\t173.06\t169.44\t172.5\t37,638,879\r\n5/30/2024\t175.2\t175.22\t171.79\t172.11\t22,958,680\r\n5/29/2024\t175.43\t176.84\t174.72\t175.9\t23,388,689\r\n5/28/2024\t174.45\t177.27\t174.37\t176.4\t20,572,160\r\n5/24/2024\t174.98\t175.77\t173.65\t174.99\t16,579,439\r\n5/23/2024\t177.07\t178.25\t172.95\t173.55\t21,024,939\r\n5/22/2024\t176.64\t177.15\t175.21\t176.38\t17,880,039\r\n5/21/2024\t176.9\t178.15\t175.81\t177.85\t16,989,369\r\n5/20/2024\t176.19\t178.77\t176.08\t176.92\t22,554,400\r\n5/17/2024\t174.18\t176.27\t173.69\t176.06\t24,479,260\r\n5/16/2024\t173.29\t175.12\t172.69\t174.18\t27,867,949\r\n5/15/2024\t170.63\t172.65\t170.51\t172.51\t26,948,369\r\n5/14/2024\t169.77\t171.25\t168.8\t170.34\t25,127,141\r\n5/13/2024\t164.26\t169.28\t164\t169.14\t31,327,600\r\n5/10/2024\t168.03\t169.85\t166.19\t168.65\t29,799,930\r\n5/9/2024\t169.39\t170.69\t168.18\t169.96\t15,346,700\r\n5/8/2024\t169\t170.15\t168.74\t169.38\t19,569,150\r\n5/7/2024\t168.5\t171.76\t168.39\t171.25\t28,039,699\r\n5/6/2024\t167.46\t168.14\t166.03\t168.1\t21,871,279\r\n5/3/2024\t167.56\t167.96\t163.05\t167.24\t34,662,434\r\n5/2/2024\t164.79\t166.73\t163.89\t166.62\t24,294,551\r\n5/1/2024\t164.3\t167.12\t163.09\t163.86\t33,493,148\r\n4/30/2024\t165.61\t168.1\t162.6\t162.78\t33,562,859\r\n4/29/2024\t169.06\t169.55\t165.21\t166.15\t45,610,020\r\n4/26/2024\t174.37\t174.71\t169.65\t171.95\t64,665,301\r\n4/25/2024\t151.33\t156.49\t150.87\t156\t57,109,727\r\n4/24/2024\t157.49\t159.57\t157.17\t159.13\t22,779,109\r\n4/23/2024\t156.96\t158.97\t156.28\t158.26\t21,151,570\r\n4/22/2024\t154.31\t157.64\t154.06\t156.28\t26,446,211\r\n4/19/2024\t156.2\t156.36\t152.3\t154.09\t32,615,641\r\n4/18/2024\t155.34\t156.94\t154.62\t156.01\t19,883,039\r\n4/17/2024\t155.62\t157.08\t154.58\t155.47\t21,763,131\r\n4/16/2024\t154.19\t155.65\t153.43\t154.4\t20,779,500\r\n4/15/2024\t158.86\t159.24\t154.59\t154.86\t27,136,471\r\n4/12/2024\t157.96\t160.22\t157.14\t157.73\t25,353,750\r\n4/11/2024\t156.91\t159.68\t156.46\t159.41\t27,166,430\r\n4/10/2024\t156.21\t156.61\t154.68\t156.14\t22,838,631\r\n4/9/2024\t156.09\t158.56\t155.19\t156.6\t31,113,010\r\n4/8/2024\t152.78\t155.27\t152.61\t154.85\t20,701,971\r\n4/5/2024\t150.03\t153.42\t149.6\t152.5\t23,459,250\r\n4/4/2024\t153.5\t154.77\t150.45\t150.53\t34,724,738\r\n4/3/2024\t153.6\t155.08\t152.73\t154.92\t24,704,990\r\n4/2/2024\t153.5\t154.7\t152.15\t154.56\t24,585,990\r\n4/1/2024\t150.69\t155.74\t150.61\t155.49\t31,730,850\r\n3/28/2024\t150.85\t151.43\t150.17\t150.93\t24,485,391\r\n3/27/2024\t151.18\t151.64\t148.9\t150.87\t22,879,180\r\n3/26/2024\t150.22\t152.26\t149.98\t150.67\t22,149,141\r\n3/25/2024\t149.94\t150.38\t147.82\t150.07\t19,229,289\r\n3/22/2024\t149.12\t151.58\t148.98\t150.77\t29,211,770\r\n3/21/2024\t149.47\t150.37\t146.9\t147.6\t24,755,600\r\n3/20/2024\t148\t148.86\t146.74\t148.74\t21,311,500\r\n3/19/2024\t148.16\t148.79\t146.08\t147.03\t24,070,439\r\n3/18/2024\t148.61\t152.15\t147.17\t147.68\t69,273,695\r\n3/15/2024\t142.5\t143.18\t140.03\t141.18\t49,475,422\r\n3/14/2024\t141.19\t143.59\t140.46\t143.1\t42,753,391\r\n3/13/2024\t139\t141.09\t138.99\t139.79\t23,347,211\r\n3/12/2024\t137.03\t139.38\t137.03\t138.5\t27,563,350\r\n3/11/2024\t136.13\t139.1\t136.13\t137.67\t32,437,770\r\n3/8/2024\t134.21\t138.09\t134\t135.41\t39,370,391\r\n3/7/2024\t132.8\t134.94\t131.61\t134.38\t37,738,207\r\n3/6/2024\t133.12\t133.58\t130.85\t131.4\t35,318,609\r\n3/5/2024\t131.88\t133.24\t130.67\t132.67\t40,194,762\r\n3/4/2024\t135.66\t135.66\t131.91\t133.35\t55,999,422\r\n3/1/2024\t138.43\t138.87\t136.92\t137.14\t31,151,119\r\n2/29/2024\t137.28\t138.86\t136.4\t138.46\t42,132,953\r\n2/28/2024\t137.9\t138.01\t135.41\t136.38\t37,328,559\r\n2/27/2024\t138.02\t139.25\t137.09\t138.88\t33,099,191\r\n2/26/2024\t142.14\t142.44\t137.39\t137.57\t53,641,801\r\n2/23/2024\t143.67\t144.68\t143.43\t143.96\t19,493,750\r\n2/22/2024\t144.93\t145\t142.8\t144.09\t27,191,891\r\n2/21/2024\t141.45\t142.69\t140.68\t142.55\t23,315,689\r\n2/20/2024\t139.66\t142.08\t139.49\t141.12\t24,935,711\r\n2/16/2024\t142.99\t143.19\t140.14\t140.52\t31,468,930\r\n2/15/2024\t143.14\t143.52\t140.46\t142.77\t37,590,699\r\n2/14/2024\t146.08\t146.52\t144.09\t145.94\t22,704,170\r\n2/13/2024\t144.92\t146.67\t143.69\t145.14\t27,837,730\r\n2/12/2024\t148.42\t149.34\t147.37\t147.53\t21,564,090\r\n2/9/2024\t146.68\t149.44\t146.18\t149\t26,829,500\r\n2/8/2024\t145.83\t146.33\t145.11\t145.91\t22,563,760\r\n2/7/2024\t144.76\t145.62\t143.93\t145.54\t25,208,859\r\n2/6/2024\t144.65\t145.36\t143.19\t144.1\t29,128,199\r\n2/5/2024\t142.82\t145.47\t142.78\t143.68\t38,505,406\r\n2/2/2024\t139.26\t142.62\t136.5\t142.38\t62,499,566\r\n2/1/2024\t142.12\t143.06\t140.79\t141.16\t40,466,551\r\n1/31/2024\t143.62\t144\t139.87\t140.1\t71,910,039\r\n1/30/2024\t152.8\t153.62\t151.19\t151.46\t36,331,832\r\n1/29/2024\t152.06\t153.78\t151.43\t153.51\t27,784,260\r\n1/26/2024\t151.1\t152.54\t151.01\t152.19\t26,115,490\r\n1/25/2024\t150.07\t153.05\t149.54\t151.87\t29,149,070\r\n1/24/2024\t148.54\t149.86\t148.1\t148.7\t25,233,449\r\n1/23/2024\t145.89\t147.18\t145.5\t147.04\t21,636,131\r\n1/22/2024\t147.1\t148.39\t145.84\t145.99\t32,200,369\r\n1/19/2024\t144.74\t146.45\t144.38\t146.38\t34,271,871\r\n1/18/2024\t142.05\t144.21\t141.99\t143.48\t25,746,420\r\n1/17/2024\t141.35\t141.84\t138.9\t141.47\t20,968,650\r\n1/16/2024\t142\t144.35\t141.45\t142.49\t22,670,471\r\n1/12/2024\t142.67\t143.2\t141.82\t142.65\t18,785,510\r\n1/11/2024\t143.49\t145.22\t140.64\t142.08\t24,008,721\r\n1/10/2024\t141\t143\t140.91\t142.28\t21,320,199\r\n1/9/2024\t138.5\t141.49\t138.15\t140.95\t24,759,600\r\n1/8/2024\t136.29\t139.01\t136.26\t138.84\t21,403,980\r\n1/5/2024\t136.75\t137.16\t135.15\t135.73\t22,513,850\r\n1/4/2024\t138.42\t139.16\t136.35\t136.39\t27,137,740\r\n1/3/2024\t137.25\t139.63\t137.08\t138.92\t24,212,150\r\n1/2/2024\t138.55\t139.45\t136.48\t138.17\t23,711,221\r\n12/29/2023\t139.63\t140.36\t138.78\t139.69\t18,733,020\r\n12/28/2023\t140.78\t141.14\t139.75\t140.23\t16,045,710\r\n12/27/2023\t141.59\t142.08\t139.89\t140.37\t19,628,619\r\n12/26/2023\t141.59\t142.68\t141.19\t141.52\t16,780,330\r\n12/22/2023\t140.77\t141.99\t140.71\t141.49\t26,532,199\r\n12/21/2023\t139.49\t140.69\t139.18\t140.42\t27,488,279\r\n12/20/2023\t138.97\t141.7\t138.07\t138.34\t49,107,180\r\n12/19/2023\t136.84\t137.47\t136.08\t136.65\t25,476,750\r\n12/18/2023\t132.63\t137.15\t132.43\t135.8\t32,257,971\r\n12/15/2023\t131.62\t133.51\t131.18\t132.6\t50,847,113\r\n12/14/2023\t133.38\t133.72\t129.69\t131.94\t38,722,406\r\n12/13/2023\t133.38\t133.5\t131.57\t132.57\t30,104,779\r\n12/12/2023\t131.81\t133\t131.26\t132.52\t29,032,830\r\n12/11/2023\t132.38\t133.34\t131.36\t133.29\t31,138,010\r\n12/8/2023\t134.2\t136.4\t134.03\t134.99\t32,260,109\r\n12/7/2023\t135.04\t138.56\t134.7\t136.93\t56,767,102\r\n12/6/2023\t131.44\t131.84\t129.88\t130.02\t23,576,180\r\n12/5/2023\t128.95\t132.14\t128.25\t130.99\t27,384,779\r\n12/4/2023\t129.88\t130.03\t127.9\t129.27\t36,669,879\r\n12/1/2023\t131.86\t132.11\t130.67\t131.86\t31,442,260\r\n11/30/2023\t135.05\t135.55\t131.28\t132.53\t38,988,262\r\n11/29/2023\t137.57\t138.29\t134.84\t134.99\t23,967,221\r\n11/28/2023\t136.08\t137.25\t135.42\t137.2\t18,730,029\r\n11/27/2023\t136.03\t138.42\t136\t136.41\t23,436,529\r\n11/24/2023\t138.03\t138.13\t135.99\t136.69\t12,514,320\r\n11/22/2023\t137.47\t139.42\t137.47\t138.49\t17,820,461\r\n11/21/2023\t136.29\t137.18\t135.96\t136.97\t22,635,270\r\n11/20/2023\t133.69\t136.66\t133.62\t136.25\t27,850,760\r\n11/17/2023\t136\t136.06\t133.65\t135.31\t37,287,688\r\n11/16/2023\t135.19\t137.22\t134.32\t136.93\t28,013,180\r\n11/15/2023\t134.87\t135.03\t133.57\t134.62\t23,861,520\r\n11/14/2023\t134.19\t135.7\t133.32\t133.62\t32,395,180\r\n11/13/2023\t131.78\t132.59\t131.25\t132.09\t18,324,750\r\n11/10/2023\t130.11\t132.8\t129.41\t132.59\t26,927,830\r\n11/9/2023\t131.96\t132.55\t130.07\t130.24\t23,747,770\r\n11/8/2023\t130.97\t132.21\t130.78\t131.84\t26,425,850\r\n11/7/2023\t130.71\t131.91\t129.88\t130.97\t29,757,279\r\n11/6/2023\t129.05\t130.34\t128.67\t130.25\t19,052,740\r\n11/3/2023\t128.02\t129.53\t127.86\t129.1\t26,393,109\r\n11/2/2023\t128.42\t128.98\t126.93\t127.49\t27,124,650\r\n11/1/2023\t124.07\t126.49\t123.72\t126.45\t30,082,439\r\n10/31/2023\t125.06\t125.37\t122.69\t124.08\t26,292,340\r\n10/30/2023\t123.21\t125.4\t122.75\t124.46\t28,940,080\r\n10/27/2023\t122.88\t123.31\t120.21\t122.17\t44,566,512\r\n10/26/2023\t123.27\t124.33\t121.27\t122.28\t57,061,141\r\n10/25/2023\t128.16\t128.31\t125.07\t125.61\t84,366,211\r\n10/24/2023\t137.83\t139.36\t137.42\t138.81\t44,814,320\r\n10/23/2023\t135.04\t137.66\t133.95\t136.5\t26,317,930\r\n10/20/2023\t137.33\t137.87\t135.08\t135.6\t26,335,670\r\n10/19/2023\t138.5\t139.66\t137.38\t137.75\t26,066,010\r\n10/18/2023\t139.45\t140.72\t137.38\t137.96\t23,375,000\r\n10/17/2023\t138.63\t139.9\t137.18\t139.72\t23,515,779\r\n10/16/2023\t138.17\t139.63\t137.99\t139.1\t28,501,869\r\n10/13/2023\t139.38\t140\t136.62\t137.36\t23,435,600\r\n10/12/2023\t141.05\t141.22\t138.26\t138.97\t24,765,539\r\n10/11/2023\t138.58\t141.11\t138.58\t140.55\t25,884,301\r\n10/10/2023\t138.5\t139.72\t137.33\t138.06\t27,786,609\r\n10/9/2023\t136.94\t138.94\t135.61\t138.42\t19,278,070\r\n10/6/2023\t134.01\t138.16\t134.01\t137.58\t27,597,600\r\n10/5/2023\t135.07\t135.49\t133.45\t135.07\t19,832,619\r\n10/4/2023\t132.79\t135.57\t132.53\t135.24\t26,752,301\r\n10/3/2023\t133.94\t134.26\t131.84\t132.43\t22,989,400\r\n10/2/2023\t131.21\t134.42\t131.17\t134.17\t22,288,039\r\n9/29/2023\t133.28\t134.05\t130.36\t130.86\t30,859,789\r\n9/28/2023\t129.84\t133.3\t129.79\t132.31\t22,513,131\r\n9/27/2023\t128.57\t130.9\t128.57\t130.54\t22,746,449\r\n9/26/2023\t129.77\t130.36\t127.22\t128.57\t25,718,699\r\n9/25/2023\t129.83\t131.17\t128.96\t131.11\t20,094,641\r\n9/22/2023\t130.76\t132.03\t129.6\t130.25\t26,397,340\r\n9/21/2023\t131.44\t132.23\t130.07\t130.44\t31,503,910\r\n9/20/2023\t138.08\t138.08\t133.62\t133.74\t29,927,480\r\n9/19/2023\t137.42\t138.41\t136.62\t138.04\t20,353,650\r\n9/18/2023\t136.61\t139.16\t136.61\t138.21\t21,861,350\r\n9/15/2023\t137.98\t138.52\t136.48\t137.4\t38,919,609\r\n9/14/2023\t137.6\t138.7\t136.24\t138.1\t24,750,971\r\n9/13/2023\t135.09\t136.9\t134.15\t136.71\t20,749,500\r\n9/12/2023\t136.26\t136.87\t135.19\t135.34\t18,405,510\r\n9/11/2023\t136.54\t137.48\t135.79\t136.92\t20,763,350\r\n9/8/2023\t134.91\t136.66\t134.85\t136.38\t23,584,189\r\n9/7/2023\t133.59\t135.58\t132.95\t135.26\t18,844,340\r\n9/6/2023\t136.02\t136.53\t133.67\t134.46\t18,684,529\r\n9/5/2023\t135.44\t136.42\t134.58\t135.77\t19,403,109\r\n9/1/2023\t137.46\t137.46\t134.85\t135.66\t21,543,689\r\n8/31/2023\t136.01\t138\t135.79\t136.17\t30,053,801\r\n8/30/2023\t134.78\t136.28\t134.07\t135.88\t28,315,770\r\n8/29/2023\t132.24\t136.57\t132.24\t134.57\t43,075,559\r\n8/28/2023\t131.31\t132.54\t130.14\t131.01\t20,543,270\r\n8/25/2023\t129.54\t130.76\t127.25\t129.88\t26,762,891\r\n8/24/2023\t133.95\t134.25\t129.57\t129.78\t28,500,689\r\n8/23/2023\t130.18\t133.41\t129.87\t132.37\t27,819,711\r\n8/22/2023\t128.51\t130.28\t128.32\t129.08\t22,067,520\r\n8/21/2023\t127.18\t128.73\t126.56\t128.37\t25,248,730\r\n8/18/2023\t128.51\t129.25\t126.38\t127.46\t30,504,770\r\n8/17/2023\t129.8\t131.99\t129.29\t129.92\t33,446,281\r\n8/16/2023\t128.7\t130.28\t127.87\t128.7\t25,216,070\r\n8/15/2023\t131.1\t131.42\t129.28\t129.78\t19,770,730\r\n8/14/2023\t129.39\t131.37\t128.96\t131.33\t24,695,609\r\n8/11/2023\t128.66\t129.93\t128.17\t129.56\t19,591,080\r\n8/10/2023\t131.32\t132.05\t129.45\t129.69\t20,857,750\r\n8/9/2023\t131.66\t132.04\t129\t129.66\t24,912,920\r\n8/8/2023\t130.62\t131.51\t129.55\t131.4\t23,535,180\r\n8/7/2023\t129.16\t131.61\t129.02\t131.53\t22,746,289\r\n8/4/2023\t129.28\t131.51\t127.91\t128.11\t26,147,160\r\n8/3/2023\t127.97\t129.39\t127.42\t128.45\t20,159,529\r\n8/2/2023\t129.45\t130.09\t127.56\t128.38\t26,273,260\r\n8/1/2023\t130.78\t132.63\t130.68\t131.55\t23,276,439\r\n7/31/2023\t132.73\t133.53\t131.78\t132.72\t28,055,529\r\n7/28/2023\t130.78\t133.74\t130.57\t132.58\t36,591,160\r\n7/27/2023\t131.67\t133.24\t128.79\t129.4\t44,952,070\r\n7/26/2023\t130.07\t130.98\t128.32\t129.27\t61,682,090\r\n7/25/2023\t121.36\t123.15\t121.02\t122.21\t52,509,551\r\n7/24/2023\t121.66\t123\t120.98\t121.53\t29,723,670\r\n7/21/2023\t120.62\t120.99\t118.73\t120.02\t71,606,469\r\n7/20/2023\t121.42\t124.09\t118.22\t119.2\t37,906,762\r\n7/19/2023\t124.6\t125.18\t121.8\t122.03\t37,224,031\r\n7/18/2023\t124.6\t124.68\t122.96\t123.76\t26,226,449\r\n7/17/2023\t125.94\t127.1\t124.2\t124.65\t25,716,221\r\n7/14/2023\t124.8\t126.78\t123.49\t125.42\t33,283,078\r\n7/13/2023\t120.93\t124.83\t120.45\t124.54\t44,297,922\r\n7/12/2023\t118.8\t120.33\t118.41\t118.93\t30,404,410\r\n7/11/2023\t116.29\t117.71\t115.35\t117.14\t23,078,779\r\n7/10/2023\t118.3\t118.31\t116.14\t116.45\t35,315,238\r\n7/7/2023\t120.1\t121.05\t119.4\t119.48\t21,709,551\r\n7/6/2023\t119.8\t120.3\t118.4\t120.11\t24,778,801\r\n7/5/2023\t119.24\t122.61\t119.23\t121.75\t27,584,811\r\n7/3/2023\t119.24\t120.19\t118.82\t119.9\t14,442,850\r\n6/30/2023\t120.17\t121.08\t119.69\t119.7\t29,532,240\r\n6/29/2023\t119.24\t120.06\t118.3\t119.1\t24,090,900\r\n6/28/2023\t117.09\t120.39\t116.85\t120.18\t27,091,449\r\n';

  final String amznStackSource =
      '6/28/2024\t197.73\t198.85\t192.5\t193.25\t76,930,195\r\n6/27/2024\t195.01\t199.84\t194.2\t197.85\t74,397,484\r\n6/26/2024\t186.92\t194.8\t186.26\t193.61\t65,103,887\r\n6/25/2024\t186.81\t188.84\t185.42\t186.34\t45,898,480\r\n6/24/2024\t189.33\t191\t185.33\t185.57\t50,610,379\r\n6/21/2024\t187.8\t189.28\t185.86\t189.08\t72,931,750\r\n6/20/2024\t182.91\t186.51\t182.72\t186.1\t44,726,781\r\n6/18/2024\t183.74\t184.29\t181.43\t182.81\t36,659,160\r\n6/17/2024\t182.52\t185\t181.22\t184.06\t35,601,910\r\n6/14/2024\t183.08\t183.72\t182.23\t183.66\t25,456,410\r\n6/13/2024\t186.09\t187.67\t182.67\t183.83\t39,721,551\r\n6/12/2024\t188.02\t188.35\t185.43\t186.89\t33,984,219\r\n6/11/2024\t187.06\t187.77\t184.54\t187.23\t27,265,109\r\n6/10/2024\t184.07\t187.23\t183.79\t187.06\t34,494,500\r\n6/7/2024\t184.9\t186.29\t183.36\t184.3\t28,021,471\r\n6/6/2024\t181.75\t185\t181.49\t185\t31,371,150\r\n6/5/2024\t180.1\t181.5\t178.75\t181.28\t32,116,391\r\n6/4/2024\t177.64\t179.82\t176.44\t179.34\t27,198,391\r\n6/3/2024\t177.7\t178.7\t175.92\t178.34\t30,786,641\r\n5/31/2024\t178.3\t179.21\t173.87\t176.44\t58,903,941\r\n5/30/2024\t181.31\t181.34\t178.36\t179.32\t29,249,230\r\n5/29/2024\t181.7\t184.08\t181.55\t182.02\t32,009,289\r\n5/28/2024\t179.93\t182.24\t179.49\t182.15\t29,926,961\r\n5/24/2024\t181.65\t182.44\t180.3\t180.75\t27,471,641\r\n5/23/2024\t183.66\t184.76\t180.08\t181.05\t33,670,168\r\n5/22/2024\t183.88\t185.22\t181.97\t183.13\t28,148,779\r\n5/21/2024\t182.3\t183.26\t180.75\t183.15\t50,839,129\r\n5/20/2024\t184.34\t186.67\t183.28\t183.54\t30,511,770\r\n5/17/2024\t183.76\t185.3\t183.35\t184.7\t33,175,660\r\n5/16/2024\t185.6\t187.31\t183.46\t183.63\t38,834,449\r\n5/15/2024\t185.97\t186.72\t182.73\t185.99\t75,459,930\r\n5/14/2024\t183.82\t187.72\t183.45\t187.07\t38,698,160\r\n5/13/2024\t188\t188.31\t185.36\t186.57\t24,898,609\r\n5/10/2024\t189.16\t189.89\t186.93\t187.48\t34,141,770\r\n5/9/2024\t188.88\t191.7\t187.44\t189.5\t43,368,379\r\n5/8/2024\t187.44\t188.43\t186.39\t188\t26,136,350\r\n5/7/2024\t188.92\t189.94\t187.31\t188.76\t34,048,898\r\n5/6/2024\t186.28\t188.75\t184.8\t188.7\t34,725,301\r\n5/3/2024\t186.99\t187.87\t185.42\t186.21\t39,172,000\r\n5/2/2024\t180.85\t185.1\t179.91\t184.72\t54,303,512\r\n5/1/2024\t181.64\t185.15\t176.56\t179\t94,645,148\r\n4/30/2024\t181.09\t182.99\t174.8\t175\t94,639,789\r\n4/29/2024\t182.75\t183.53\t179.39\t180.96\t54,063,941\r\n4/26/2024\t177.8\t180.82\t176.13\t179.62\t43,919,770\r\n4/25/2024\t169.68\t173.92\t166.32\t173.67\t49,249,391\r\n4/24/2024\t179.94\t180.32\t176.18\t176.59\t34,185,113\r\n4/23/2024\t178.08\t179.93\t175.98\t179.54\t37,046,520\r\n4/22/2024\t176.94\t178.87\t174.56\t177.23\t37,924,887\r\n4/19/2024\t178.74\t179\t173.44\t174.63\t56,000,727\r\n4/18/2024\t181.47\t182.39\t178.65\t179.22\t30,723,789\r\n4/17/2024\t184.31\t184.57\t179.82\t181.28\t31,359,670\r\n4/16/2024\t183.27\t184.83\t182.26\t183.32\t32,891,270\r\n4/15/2024\t187.43\t188.69\t183\t183.62\t48,052,398\r\n4/12/2024\t187.72\t188.38\t185.08\t186.13\t38,608,848\r\n4/11/2024\t186.74\t189.77\t185.51\t189.05\t40,020,738\r\n4/10/2024\t182.77\t186.27\t182.67\t185.95\t35,879,152\r\n4/9/2024\t187.24\t187.34\t184.2\t185.67\t36,546,953\r\n4/8/2024\t186.9\t187.29\t184.81\t185.19\t39,221,281\r\n4/5/2024\t182.38\t186.27\t181.97\t185.07\t42,373,992\r\n4/4/2024\t184\t185.1\t180\t180\t41,624,262\r\n4/3/2024\t179.9\t182.87\t179.8\t182.41\t31,046,641\r\n4/2/2024\t179.07\t180.79\t178.38\t180.69\t32,611,551\r\n4/1/2024\t180.79\t183\t179.95\t180.97\t29,174,520\r\n3/28/2024\t180.17\t181.7\t179.26\t180.38\t38,051,594\r\n3/27/2024\t179.88\t180\t177.31\t179.83\t33,272,551\r\n3/26/2024\t180.15\t180.45\t177.95\t178.3\t29,658,980\r\n3/25/2024\t178.01\t180.99\t177.24\t179.71\t29,815,461\r\n3/22/2024\t177.75\t179.26\t176.75\t178.87\t27,995,381\r\n3/21/2024\t179.99\t181.42\t178.15\t178.15\t32,824,320\r\n3/20/2024\t176.14\t178.53\t174.64\t178.15\t29,947,150\r\n3/19/2024\t174.22\t176.09\t173.52\t175.9\t26,880,891\r\n3/18/2024\t175.8\t176.69\t174.28\t174.48\t31,250,689\r\n3/15/2024\t176.64\t177.93\t173.9\t174.42\t72,147,391\r\n3/14/2024\t177.69\t179.53\t176.47\t178.75\t43,705,840\r\n3/13/2024\t175.9\t177.62\t175.55\t176.56\t30,772,600\r\n3/12/2024\t173.5\t176.76\t171.98\t175.39\t36,610,602\r\n3/11/2024\t174.31\t174.47\t171.47\t171.96\t28,484,779\r\n3/8/2024\t176.44\t178.79\t174.33\t175.35\t37,893,238\r\n3/7/2024\t174.83\t177.99\t173.72\t176.82\t34,063,281\r\n3/6/2024\t175.54\t176.46\t173.26\t173.51\t32,090,930\r\n3/5/2024\t176.93\t176.93\t173.3\t174.12\t37,228,340\r\n3/4/2024\t177.53\t180.14\t177.49\t177.58\t37,381,520\r\n3/1/2024\t176.75\t178.73\t176.07\t178.22\t31,981,150\r\n2/29/2024\t173.01\t177.22\t172.85\t176.76\t53,805,359\r\n2/28/2024\t172.44\t174.05\t172.27\t173.16\t28,180,480\r\n2/27/2024\t174.08\t174.62\t172.86\t173.54\t31,141,730\r\n2/26/2024\t175.7\t176.37\t174.26\t174.73\t44,368,609\r\n2/23/2024\t174.28\t175.75\t173.7\t174.99\t59,715,238\r\n2/22/2024\t173.1\t174.8\t171.77\t174.58\t55,392,352\r\n2/21/2024\t168.94\t170.23\t167.14\t168.59\t44,575,621\r\n2/20/2024\t167.83\t168.71\t165.74\t167.08\t41,980,328\r\n2/16/2024\t168.74\t170.42\t167.17\t169.51\t48,107,738\r\n2/15/2024\t170.58\t171.17\t167.59\t169.8\t49,855,199\r\n2/14/2024\t169.21\t171.21\t168.28\t170.98\t42,815,539\r\n2/13/2024\t167.73\t170.95\t165.75\t168.64\t56,345,121\r\n2/12/2024\t174.8\t175.39\t171.54\t172.34\t51,050,441\r\n2/9/2024\t170.9\t175\t170.58\t174.45\t56,985,992\r\n2/8/2024\t169.65\t171.43\t168.88\t169.84\t42,316,449\r\n2/7/2024\t169.48\t170.88\t168.94\t170.53\t47,174,059\r\n2/6/2024\t169.39\t170.71\t167.65\t169.15\t42,505,520\r\n2/5/2024\t170.2\t170.55\t167.7\t170.31\t55,081,301\r\n2/2/2024\t169.19\t172.5\t167.33\t171.81\t117,218,305\r\n2/1/2024\t155.87\t159.76\t155.62\t159.28\t76,542,414\r\n1/31/2024\t157\t159.01\t154.81\t155.2\t50,284,367\r\n1/30/2024\t160.7\t161.73\t158.49\t159\t45,207,434\r\n1/29/2024\t159.34\t161.29\t158.9\t161.26\t45,270,391\r\n1/26/2024\t158.42\t160.72\t157.91\t159.12\t51,047,352\r\n1/25/2024\t156.95\t158.51\t154.55\t157.75\t43,638,594\r\n1/24/2024\t157.8\t158.51\t156.48\t156.87\t48,547,320\r\n1/23/2024\t154.85\t156.21\t153.93\t156.02\t37,986,039\r\n1/22/2024\t156.89\t157.05\t153.9\t154.78\t43,687,473\r\n1/19/2024\t153.83\t155.76\t152.74\t155.34\t51,651,633\r\n1/18/2024\t152.77\t153.78\t151.82\t153.5\t37,850,246\r\n1/17/2024\t151.49\t152.15\t149.91\t151.71\t34,953,359\r\n1/16/2024\t153.53\t154.99\t152.15\t153.16\t41,384,641\r\n1/12/2024\t155.39\t156.2\t154.01\t154.62\t40,484,160\r\n1/11/2024\t155.04\t157.17\t153.12\t155.18\t49,072,688\r\n1/10/2024\t152.06\t154.42\t151.88\t153.73\t44,421,832\r\n1/9/2024\t148.33\t151.71\t148.21\t151.37\t43,812,566\r\n1/8/2024\t146.74\t149.4\t146.15\t149.1\t46,757,047\r\n1/5/2024\t144.69\t146.59\t144.53\t145.24\t45,153,152\r\n1/4/2024\t145.59\t147.38\t144.05\t144.57\t56,039,809\r\n1/3/2024\t149.2\t151.05\t148.33\t148.47\t49,425,500\r\n1/2/2024\t151.54\t152.38\t148.39\t149.93\t47,339,422\r\n12/29/2023\t153.1\t153.89\t151.03\t151.94\t39,823,199\r\n12/28/2023\t153.72\t154.08\t152.95\t153.38\t27,057,000\r\n12/27/2023\t153.56\t154.78\t153.12\t153.34\t31,434,730\r\n12/26/2023\t153.56\t153.98\t153.03\t153.41\t25,067,221\r\n12/22/2023\t153.77\t154.35\t152.71\t153.42\t29,514,090\r\n12/21/2023\t153.3\t153.97\t152.1\t153.84\t36,305,727\r\n12/20/2023\t152.9\t155.63\t151.56\t152.12\t50,322,113\r\n12/19/2023\t154.4\t155.12\t152.69\t153.79\t43,171,289\r\n12/18/2023\t150.56\t154.86\t150.05\t154.07\t62,512,832\r\n12/15/2023\t148.38\t150.57\t147.88\t149.97\t110,089,297\r\n12/14/2023\t149.93\t150.54\t145.52\t147.42\t58,400,848\r\n12/13/2023\t148.12\t149.46\t146.82\t148.84\t52,766,199\r\n12/12/2023\t145.52\t147.5\t145.3\t147.48\t44,944,262\r\n12/11/2023\t145.66\t146.19\t143.64\t145.89\t50,907,289\r\n12/8/2023\t145.48\t147.84\t145.4\t147.42\t41,905,969\r\n12/7/2023\t146.15\t147.92\t145.34\t146.88\t52,352,832\r\n12/6/2023\t147.58\t147.85\t144.28\t144.52\t39,678,961\r\n12/5/2023\t143.55\t148.57\t143.13\t146.88\t46,822,406\r\n12/4/2023\t145.25\t145.35\t142.81\t144.84\t48,294,238\r\n12/1/2023\t146\t147.25\t145.55\t147.03\t39,951,832\r\n11/30/2023\t144.76\t146.93\t144.33\t146.09\t65,814,023\r\n11/29/2023\t147.85\t148.54\t145.97\t146.32\t40,610,910\r\n11/28/2023\t146.98\t147.6\t145.53\t147.03\t42,711,680\r\n11/27/2023\t147.53\t149.26\t146.88\t147.73\t53,762,434\r\n11/24/2023\t146.7\t147.2\t145.32\t146.74\t22,378,381\r\n11/22/2023\t144.57\t147.74\t144.57\t146.71\t45,700,000\r\n11/21/2023\t143.91\t144.05\t141.5\t143.9\t71,225,992\r\n11/20/2023\t145.13\t146.63\t144.73\t146.13\t41,978,770\r\n11/17/2023\t142.66\t145.23\t142.55\t145.18\t49,678,441\r\n11/16/2023\t140.91\t143.32\t139.52\t142.83\t49,653,512\r\n11/15/2023\t147.06\t147.29\t142.59\t143.2\t63,875,719\r\n11/14/2023\t145\t147.26\t144.68\t145.8\t56,674,551\r\n11/13/2023\t142.08\t143.23\t140.67\t142.59\t35,680,566\r\n11/10/2023\t140.46\t143.65\t139.91\t143.56\t49,349,941\r\n11/9/2023\t142.02\t142.65\t139.84\t140.6\t36,235,367\r\n11/8/2023\t142.97\t143.12\t141.22\t142.08\t44,521,660\r\n11/7/2023\t140.55\t143.37\t140.5\t142.71\t53,553,539\r\n11/6/2023\t138.76\t140.73\t138.36\t139.74\t44,970,422\r\n11/3/2023\t138.99\t139.49\t137.45\t138.6\t44,059,809\r\n11/2/2023\t138.73\t138.81\t136.47\t138.07\t52,236,688\r\n11/1/2023\t133.96\t137.35\t133.71\t137\t61,529,406\r\n10/31/2023\t132.75\t133.57\t131.71\t133.09\t51,589,379\r\n10/30/2023\t129.72\t133\t128.56\t132.71\t72,485,539\r\n10/27/2023\t126.2\t130.02\t125.52\t127.74\t125,309,297\r\n10/26/2023\t120.63\t121.64\t118.35\t119.57\t100,419,508\r\n10/25/2023\t126.04\t126.34\t120.79\t121.39\t74,577,539\r\n10/24/2023\t127.74\t128.8\t126.34\t128.56\t46,477,359\r\n10/23/2023\t124.63\t127.88\t123.98\t126.56\t48,259,953\r\n10/20/2023\t128.05\t128.17\t124.97\t125.17\t56,406,406\r\n10/19/2023\t130.57\t132.24\t127.47\t128.4\t60,961,359\r\n10/18/2023\t129.9\t130.67\t127.51\t128.13\t42,699,480\r\n10/17/2023\t130.39\t132.58\t128.71\t131.47\t49,344,551\r\n10/16/2023\t130.69\t133.07\t130.43\t132.55\t42,832,922\r\n10/13/2023\t132.98\t133.31\t128.95\t129.79\t45,824,688\r\n10/12/2023\t132.17\t134.48\t131.23\t132.33\t55,528,578\r\n10/11/2023\t129.74\t132.05\t129.61\t131.83\t40,741,840\r\n10/10/2023\t128.82\t130.74\t128.05\t129.48\t42,178,621\r\n10/9/2023\t126.22\t128.79\t124.76\t128.26\t38,773,738\r\n10/6/2023\t124.16\t128.45\t124.13\t127.96\t46,836,699\r\n10/5/2023\t126.71\t126.73\t124.33\t125.96\t39,660,641\r\n10/4/2023\t126.06\t127.36\t125.68\t127\t44,203,871\r\n10/3/2023\t128.06\t128.52\t124.25\t124.72\t51,564,992\r\n10/2/2023\t127.28\t130.47\t126.54\t129.46\t48,029,738\r\n9/29/2023\t128.2\t129.15\t126.32\t127.12\t62,411,727\r\n9/28/2023\t124.04\t126.58\t123.04\t125.98\t54,554,969\r\n9/27/2023\t125.76\t127.48\t124.13\t125.98\t66,553,445\r\n9/26/2023\t130.12\t130.39\t125.28\t125.98\t73,048,211\r\n9/25/2023\t129.36\t131.78\t128.77\t131.27\t46,017,832\r\n9/22/2023\t131.11\t132.03\t128.52\t129.12\t59,904,352\r\n9/21/2023\t131.94\t132.24\t129.31\t129.33\t70,343,344\r\n9/20/2023\t138.55\t139.37\t135.2\t135.29\t46,263,719\r\n9/19/2023\t138.7\t138.84\t135.56\t137.63\t61,482,473\r\n9/18/2023\t140.48\t141.75\t139.22\t139.98\t42,823,480\r\n9/15/2023\t142.69\t143.57\t140.09\t140.39\t102,909,297\r\n9/14/2023\t145.08\t145.86\t142.95\t144.72\t64,033,609\r\n9/13/2023\t140.95\t144.98\t140.87\t144.85\t60,465,180\r\n9/12/2023\t142.32\t143\t140.61\t141.23\t42,668,449\r\n9/11/2023\t138.75\t143.62\t138.64\t143.1\t56,764,527\r\n9/8/2023\t136.86\t138.85\t136.75\t138.23\t38,365,930\r\n9/7/2023\t133.9\t138.03\t133.16\t137.85\t48,498,910\r\n9/6/2023\t136.32\t137.45\t134.61\t135.36\t41,785,512\r\n9/5/2023\t137.73\t137.8\t135.82\t137.27\t40,636,738\r\n9/1/2023\t139.46\t139.96\t136.88\t138.12\t40,991,539\r\n8/31/2023\t135.06\t138.79\t135\t138.01\t58,781,312\r\n8/30/2023\t134.93\t135.68\t133.92\t135.07\t36,137,020\r\n8/29/2023\t133.38\t135.14\t133.25\t134.91\t38,646,090\r\n8/28/2023\t133.78\t133.95\t131.85\t133.14\t34,108,406\r\n8/25/2023\t132.47\t133.87\t130.58\t133.26\t44,147,449\r\n8/24/2023\t136.4\t136.78\t131.83\t131.84\t43,646,246\r\n8/23/2023\t134.5\t135.95\t133.22\t135.52\t42,801,039\r\n8/22/2023\t135.08\t135.65\t133.73\t134.25\t32,935,102\r\n8/21/2023\t133.74\t135.19\t132.71\t134.68\t41,442,480\r\n8/18/2023\t131.62\t134.07\t131.15\t133.22\t48,497,699\r\n8/17/2023\t135.46\t136.09\t133.53\t133.98\t48,354,090\r\n8/16/2023\t137.19\t137.27\t135.01\t135.07\t41,675,898\r\n8/15/2023\t140.05\t141.28\t137.23\t137.67\t42,781,520\r\n8/14/2023\t138.3\t140.59\t137.75\t140.57\t47,148,699\r\n8/11/2023\t137.4\t139.33\t137\t138.41\t42,905,832\r\n8/10/2023\t139.08\t140.41\t137.49\t138.56\t58,928,398\r\n8/9/2023\t139.97\t140.32\t137.1\t137.85\t50,017,352\r\n8/8/2023\t140.62\t140.84\t138.42\t139.94\t51,710,500\r\n8/7/2023\t140.99\t142.54\t138.95\t142.22\t71,213,109\r\n8/4/2023\t141.06\t143.63\t139.32\t139.57\t153,128,500\r\n8/3/2023\t127.48\t129.84\t126.41\t128.91\t91,163,742\r\n8/2/2023\t130.15\t130.23\t126.82\t128.21\t51,027,609\r\n8/1/2023\t133.55\t133.69\t131.62\t131.69\t42,298,930\r\n7/31/2023\t133.2\t133.87\t132.38\t133.68\t41,901,520\r\n7/28/2023\t129.69\t133.01\t129.33\t132.21\t46,317,379\r\n7/27/2023\t131\t132.63\t127.79\t128.25\t52,610,660\r\n7/26/2023\t126.51\t129.08\t126.11\t128.15\t53,910,090\r\n7/25/2023\t129.31\t129.58\t128.53\t129.13\t39,236,660\r\n7/24/2023\t130.31\t131.66\t128.35\t128.8\t45,671,539\r\n7/21/2023\t131.34\t131.37\t128.42\t130\t133,307,297\r\n7/20/2023\t134.07\t134.79\t129.33\t129.96\t59,820,578\r\n7/19/2023\t133.39\t135.99\t132.53\t135.36\t54,531,039\r\n7/18/2023\t132.71\t133.86\t131.36\t132.83\t54,969,129\r\n7/17/2023\t134.56\t135.62\t133.21\t133.56\t48,450,199\r\n7/14/2023\t134.06\t136.65\t134.06\t134.68\t54,487,090\r\n7/13/2023\t134.04\t134.67\t132.71\t134.3\t61,170,879\r\n7/12/2023\t130.31\t131.26\t128.83\t130.8\t54,022,848\r\n7/11/2023\t127.75\t129.77\t127.35\t128.78\t49,951,461\r\n7/10/2023\t129.07\t129.28\t125.92\t127.13\t61,889,289\r\n7/7/2023\t128.59\t130.97\t128.13\t129.78\t41,992,246\r\n7/6/2023\t128.25\t128.73\t127.37\t128.36\t40,697,848\r\n7/5/2023\t130.24\t131.4\t129.64\t130.38\t35,895,406\r\n7/3/2023\t130.82\t131.85\t130.07\t130.22\t27,939,570\r\n6/30/2023\t129.47\t131.25\t128.95\t130.36\t54,350,680\r\n6/29/2023\t128.77\t129.26\t127.26\t127.9\t40,760,961\r\n6/28/2023\t128.94\t131.48\t128.44\t129.04\t52,149,512\r\n';

  final String teslaStackSource =
      '6/28/2024\t199.55\t203.2\t195.26\t197.88\t95,438,070\r\n6/27/2024\t195.17\t198.72\t194.05\t197.42\t72,746,523\r\n6/26/2024\t186.54\t197.76\t186.36\t196.37\t95,737,070\r\n6/25/2024\t184.4\t187.97\t182.01\t187.35\t63,678,273\r\n6/24/2024\t184.97\t188.8\t182.55\t182.58\t61,992,070\r\n6/21/2024\t182.3\t183.95\t180.69\t183.01\t63,029,480\r\n6/20/2024\t184.68\t185.21\t179.66\t181.57\t55,893,141\r\n6/18/2024\t186.56\t187.2\t182.37\t184.86\t68,982,273\r\n6/17/2024\t177.92\t188.81\t177\t187.44\t109,786,094\r\n6/14/2024\t185.8\t186\t176.92\t178.01\t82,038,195\r\n6/13/2024\t188.39\t191.08\t181.23\t182.47\t118,984,094\r\n6/12/2024\t171.12\t180.55\t169.8\t177.29\t90,389,445\r\n6/11/2024\t173.92\t174.75\t167.41\t170.66\t64,761,930\r\n6/10/2024\t176.06\t178.57\t173.17\t173.79\t50,869,680\r\n6/7/2024\t176.13\t179.35\t175.58\t177.48\t56,244,930\r\n6/6/2024\t174.6\t179.73\t172.73\t177.94\t69,887,023\r\n6/5/2024\t175.35\t176.15\t172.13\t175\t57,953,762\r\n6/4/2024\t174.78\t177.76\t174\t174.77\t60,056,340\r\n6/3/2024\t178.13\t182.64\t174.49\t176.29\t68,568,922\r\n5/31/2024\t178.5\t180.32\t173.82\t178.08\t67,314,602\r\n5/30/2024\t178.58\t182.67\t175.38\t178.79\t77,784,758\r\n5/29/2024\t174.19\t178.15\t173.93\t176.19\t54,782,648\r\n5/28/2024\t176.4\t178.25\t173.16\t176.75\t59,736,621\r\n5/24/2024\t174.84\t180.08\t173.73\t179.24\t65,584,477\r\n5/23/2024\t181.8\t181.9\t173.26\t173.74\t71,975,508\r\n5/22/2024\t182.85\t183.8\t178.12\t180.11\t88,313,477\r\n5/21/2024\t175.51\t186.88\t174.71\t186.6\t115,266,492\r\n5/20/2024\t177.56\t177.75\t173.52\t174.95\t61,727,434\r\n5/17/2024\t173.55\t179.63\t172.75\t177.46\t77,445,852\r\n5/16/2024\t174.1\t175.79\t171.43\t174.84\t59,812,219\r\n5/15/2024\t179.9\t180\t173.11\t173.99\t79,662,992\r\n5/14/2024\t174.5\t179.49\t174.07\t177.55\t86,407,422\r\n5/13/2024\t170\t175.4\t169\t171.89\t67,018,898\r\n5/10/2024\t173.05\t173.06\t167.75\t168.47\t72,627,188\r\n5/9/2024\t175.01\t175.62\t171.37\t171.97\t65,950,289\r\n5/8/2024\t171.59\t176.06\t170.15\t174.72\t79,969,484\r\n5/7/2024\t182.4\t183.26\t177.4\t177.81\t75,045,852\r\n5/6/2024\t183.8\t187.56\t182.2\t184.76\t84,390,250\r\n5/3/2024\t182.1\t184.78\t178.42\t181.19\t75,491,539\r\n5/2/2024\t182.86\t184.6\t176.02\t180.01\t89,148,039\r\n5/1/2024\t182\t185.86\t179.01\t179.99\t92,829,719\r\n4/30/2024\t186.98\t190.95\t182.84\t183.28\t127,031,797\r\n4/29/2024\t188.42\t198.87\t184.54\t194.05\t243,869,703\r\n4/26/2024\t168.85\t172.12\t166.37\t168.29\t109,815,695\r\n4/25/2024\t158.96\t170.88\t158.36\t170.18\t126,427,508\r\n4/24/2024\t162.84\t167.97\t157.51\t162.13\t181,178,000\r\n4/23/2024\t143.33\t147.26\t141.11\t144.68\t124,545,102\r\n4/22/2024\t140.56\t144.44\t138.8\t142.05\t107,097,602\r\n4/19/2024\t148.97\t150.94\t146.22\t147.05\t87,074,492\r\n4/18/2024\t151.25\t152.2\t148.7\t149.93\t96,098,828\r\n4/17/2024\t157.64\t158.33\t153.78\t155.45\t82,439,719\r\n4/16/2024\t156.74\t158.19\t153.75\t157.11\t96,999,961\r\n4/15/2024\t170.24\t170.69\t161.38\t161.48\t100,245,297\r\n4/12/2024\t172.34\t173.81\t170.36\t171.05\t64,722,672\r\n4/11/2024\t172.55\t175.88\t168.51\t174.6\t94,515,992\r\n4/10/2024\t173.04\t174.93\t170.01\t171.76\t84,532,406\r\n4/9/2024\t172.91\t179.22\t171.92\t176.88\t103,232,703\r\n4/8/2024\t169.34\t174.5\t167.79\t172.98\t104,423,297\r\n4/5/2024\t169.08\t170.86\t160.51\t164.9\t143,157,594\r\n4/4/2024\t170.07\t177.19\t168.01\t171.11\t123,162,000\r\n4/3/2024\t164.02\t168.82\t163.28\t168.38\t82,950,141\r\n4/2/2024\t164.75\t167.69\t163.43\t166.63\t116,650,602\r\n4/1/2024\t176.17\t176.75\t170.21\t175.22\t81,562,125\r\n3/28/2024\t177.45\t179.57\t175.3\t175.79\t77,654,844\r\n3/27/2024\t181.41\t181.91\t176\t179.83\t81,804,039\r\n3/26/2024\t178.58\t184.25\t177.38\t177.67\t113,186,203\r\n3/25/2024\t168.76\t175.24\t168.73\t172.63\t74,228,625\r\n3/22/2024\t166.69\t171.2\t166.3\t170.83\t75,580,641\r\n3/21/2024\t176.39\t178.18\t171.8\t172.82\t73,178,008\r\n3/20/2024\t173\t176.25\t170.82\t175.66\t83,846,727\r\n3/19/2024\t172.36\t172.82\t167.42\t171.32\t77,271,430\r\n3/18/2024\t170.02\t174.72\t165.9\t173.8\t108,214,398\r\n3/15/2024\t163.16\t165.18\t160.76\t163.57\t97,146,828\r\n3/14/2024\t167.77\t171.17\t160.51\t162.5\t126,325,695\r\n3/13/2024\t173.05\t176.05\t169.15\t169.48\t106,524,492\r\n3/12/2024\t177.77\t179.43\t172.41\t177.54\t87,391,680\r\n3/11/2024\t175.45\t182.87\t174.8\t177.77\t85,391,531\r\n3/8/2024\t181.5\t182.73\t174.7\t175.34\t85,544,641\r\n3/7/2024\t174.35\t180.04\t173.7\t178.65\t102,129,000\r\n3/6/2024\t179.99\t181.58\t173.7\t176.54\t107,920,898\r\n3/5/2024\t183.05\t184.59\t177.57\t180.74\t119,660,797\r\n3/4/2024\t198.73\t199.75\t186.72\t188.14\t134,334,891\r\n3/1/2024\t200.52\t204.52\t198.5\t202.64\t82,243,117\r\n2/29/2024\t204.18\t205.28\t198.45\t201.88\t85,906,969\r\n2/28/2024\t200.42\t205.3\t198.44\t202.04\t99,806,172\r\n2/27/2024\t204.04\t205.6\t198.26\t199.73\t108,645,398\r\n2/26/2024\t192.29\t201.78\t192\t199.4\t111,747,102\r\n2/23/2024\t195.31\t197.57\t191.5\t191.97\t78,841,922\r\n2/22/2024\t194\t198.32\t191.36\t197.41\t92,739,453\r\n2/21/2024\t193.36\t199.44\t191.95\t194.77\t103,844,000\r\n2/20/2024\t196.13\t198.6\t189.13\t193.76\t104,545,797\r\n2/16/2024\t202.06\t203.17\t197.4\t199.95\t111,346,703\r\n2/15/2024\t189.16\t200.88\t188.86\t200.45\t120,831,797\r\n2/14/2024\t185.3\t188.89\t183.35\t188.71\t81,202,992\r\n2/13/2024\t183.99\t187.26\t182.11\t184.02\t86,759,477\r\n2/12/2024\t192.11\t194.73\t187.28\t188.13\t95,498,602\r\n2/9/2024\t190.18\t194.12\t189.48\t193.57\t84,476,352\r\n2/8/2024\t189\t191.62\t185.58\t189.56\t83,034,039\r\n2/7/2024\t188.18\t189.79\t182.68\t187.58\t111,535,203\r\n2/6/2024\t177.21\t186.49\t177.11\t185.1\t122,676,000\r\n2/5/2024\t184.26\t184.68\t175.01\t181.06\t134,294,406\r\n2/2/2024\t185.04\t188.69\t182\t187.91\t110,612,703\r\n2/1/2024\t188.5\t189.88\t184.28\t188.86\t91,843,281\r\n1/31/2024\t187\t193.97\t185.85\t187.29\t103,221,398\r\n1/30/2024\t195.33\t196.36\t190.61\t191.59\t109,982,305\r\n1/29/2024\t185.63\t191.48\t183.67\t190.93\t125,013,102\r\n1/26/2024\t185.5\t186.78\t182.1\t183.25\t107,343,203\r\n1/25/2024\t189.7\t193\t180.06\t182.63\t198,076,797\r\n1/24/2024\t211.88\t212.73\t206.77\t207.83\t123,369,906\r\n1/23/2024\t211.3\t215.65\t207.75\t209.14\t106,605,906\r\n1/22/2024\t212.26\t217.8\t206.27\t208.8\t117,952,492\r\n1/19/2024\t209.99\t213.19\t207.56\t212.19\t102,260,305\r\n1/18/2024\t216.88\t217.45\t208.74\t211.88\t108,595,398\r\n1/17/2024\t214.86\t215.67\t212.01\t215.55\t103,164,398\r\n1/16/2024\t215.1\t223.49\t212.18\t219.91\t115,355,000\r\n1/12/2024\t220.08\t225.34\t217.15\t218.89\t123,043,797\r\n1/11/2024\t230.57\t230.93\t225.37\t227.22\t105,873,602\r\n1/10/2024\t235.1\t235.5\t231.29\t233.94\t91,628,492\r\n1/9/2024\t238.11\t238.96\t232.04\t234.96\t96,705,664\r\n1/8/2024\t236.14\t241.25\t235.3\t240.45\t85,166,578\r\n1/5/2024\t236.86\t240.12\t234.9\t237.49\t92,488,945\r\n1/4/2024\t239.25\t242.7\t237.73\t237.93\t102,629,297\r\n1/3/2024\t244.98\t245.68\t236.32\t238.45\t121,082,602\r\n1/2/2024\t250.08\t251.25\t244.41\t248.42\t104,654,203\r\n12/29/2023\t255.1\t255.19\t247.43\t248.48\t100,891,602\r\n12/28/2023\t263.66\t265.13\t252.71\t253.18\t113,619,906\r\n12/27/2023\t258.35\t263.34\t257.52\t261.44\t106,494,398\r\n12/26/2023\t254.49\t257.97\t252.91\t256.61\t86,892,383\r\n12/22/2023\t256.76\t258.22\t251.37\t252.54\t93,370,086\r\n12/21/2023\t251.9\t254.8\t248.55\t254.5\t109,594,203\r\n12/20/2023\t256.41\t259.84\t247\t247.14\t125,097,000\r\n12/19/2023\t253.48\t258.34\t253.01\t257.22\t106,737,398\r\n12/18/2023\t253.78\t258.74\t251.36\t252.08\t116,416,492\r\n12/15/2023\t251.21\t254.13\t248.3\t253.5\t135,932,797\r\n12/14/2023\t241.22\t253.88\t240.79\t251.05\t160,829,203\r\n12/13/2023\t234.19\t240.3\t228.2\t239.29\t146,286,297\r\n12/12/2023\t238.55\t238.99\t233.87\t237.01\t95,328,312\r\n12/11/2023\t242.74\t243.44\t237.45\t239.74\t97,913,891\r\n12/8/2023\t240.27\t245.27\t239.27\t243.84\t103,126,797\r\n12/7/2023\t241.55\t244.08\t236.98\t242.64\t107,142,305\r\n12/6/2023\t242.92\t246.57\t239.17\t239.37\t126,436,203\r\n12/5/2023\t233.87\t246.66\t233.7\t238.72\t137,971,109\r\n12/4/2023\t235.75\t239.37\t233.29\t235.58\t104,099,797\r\n12/1/2023\t233.14\t240.19\t231.9\t238.83\t121,331,695\r\n11/30/2023\t245.14\t245.22\t236.91\t240.08\t132,353,203\r\n11/29/2023\t249.21\t252.75\t242.76\t244.14\t135,401,297\r\n11/28/2023\t236.68\t247\t234.01\t246.72\t148,549,906\r\n11/27/2023\t236.89\t238.33\t232.1\t236.08\t112,031,797\r\n11/24/2023\t233.75\t238.75\t232.33\t235.45\t65,125,199\r\n11/22/2023\t242.04\t244.01\t231.4\t234.21\t118,117,102\r\n11/21/2023\t235.04\t243.62\t233.34\t241.2\t122,288,000\r\n11/20/2023\t234.04\t237.1\t231.02\t235.6\t116,562,398\r\n11/17/2023\t232\t237.39\t226.54\t234.3\t142,766,203\r\n11/16/2023\t239.49\t240.88\t230.96\t233.59\t136,816,797\r\n11/15/2023\t239.29\t246.7\t236.45\t242.84\t150,354,000\r\n11/14/2023\t235.03\t238.14\t230.72\t237.41\t149,771,594\r\n11/13/2023\t215.6\t225.4\t211.61\t223.71\t140,447,594\r\n11/10/2023\t210.03\t215.38\t205.69\t214.65\t131,310,094\r\n11/9/2023\t219.75\t220.8\t206.68\t209.98\t142,110,500\r\n11/8/2023\t223.15\t224.15\t217.64\t222.11\t106,584,797\r\n11/7/2023\t219.98\t223.12\t215.72\t222.18\t116,900,094\r\n11/6/2023\t223.98\t226.32\t215\t219.27\t117,335,797\r\n11/3/2023\t221.15\t226.37\t218.4\t219.96\t119,534,797\r\n11/2/2023\t212.97\t219.2\t211.45\t218.51\t125,987,602\r\n11/1/2023\t204.04\t205.99\t197.85\t205.66\t121,661,695\r\n10/31/2023\t196.12\t202.8\t194.07\t200.84\t118,068,305\r\n10/30/2023\t209.28\t210.88\t194.67\t197.36\t136,448,188\r\n10/27/2023\t210.6\t212.41\t205.77\t207.3\t94,881,172\r\n10/26/2023\t211.32\t214.8\t204.88\t205.76\t115,112,602\r\n10/25/2023\t215.88\t220.1\t212.2\t212.42\t107,065,102\r\n10/24/2023\t216.5\t222.05\t214.11\t216.52\t118,231,102\r\n10/23/2023\t210\t216.98\t202.51\t212.08\t150,683,391\r\n10/20/2023\t217.01\t218.86\t210.42\t211.99\t138,010,094\r\n10/19/2023\t225.95\t230.61\t216.78\t220.11\t170,772,703\r\n10/18/2023\t252.7\t254.63\t242.08\t242.68\t125,147,797\r\n10/17/2023\t250.1\t257.18\t247.08\t254.85\t93,562,914\r\n10/16/2023\t250.05\t255.4\t248.48\t253.92\t88,917,188\r\n10/13/2023\t258.9\t259.6\t250.22\t251.12\t102,296,797\r\n10/12/2023\t262.92\t265.41\t256.63\t258.87\t111,508,094\r\n10/11/2023\t266.2\t268.6\t260.9\t262.99\t103,706,305\r\n10/10/2023\t257.75\t268.94\t257.65\t263.62\t122,656,000\r\n10/9/2023\t255.31\t261.36\t252.05\t259.67\t101,377,906\r\n10/6/2023\t253.98\t261.65\t250.65\t260.53\t118,121,797\r\n10/5/2023\t260\t263.6\t256.25\t260.05\t119,159,203\r\n10/4/2023\t248.14\t261.86\t247.6\t261.16\t129,721,602\r\n10/3/2023\t248.61\t250.02\t244.45\t246.53\t101,985,297\r\n10/2/2023\t244.81\t254.28\t242.62\t251.6\t123,810,398\r\n9/29/2023\t250\t254.77\t246.35\t250.22\t128,522,703\r\n9/28/2023\t240.02\t247.55\t238.65\t246.38\t117,058,898\r\n9/27/2023\t244.26\t245.33\t234.58\t240.5\t136,597,203\r\n9/26/2023\t242.98\t249.55\t241.66\t244.12\t101,993,602\r\n9/25/2023\t243.38\t247.1\t238.31\t246.99\t104,636,602\r\n9/22/2023\t257.4\t257.79\t244.48\t244.88\t127,524,094\r\n9/21/2023\t257.85\t260.86\t254.21\t255.7\t119,951,508\r\n9/20/2023\t267.04\t273.93\t262.46\t262.59\t122,514,602\r\n9/19/2023\t264.35\t267.85\t261.2\t266.5\t103,704,000\r\n9/18/2023\t271.16\t271.44\t263.76\t265.28\t101,543,297\r\n9/15/2023\t277.55\t278.98\t271\t274.39\t133,692,297\r\n9/14/2023\t271.32\t276.71\t270.42\t276.04\t107,709,797\r\n9/13/2023\t270.07\t274.98\t268.1\t271.3\t111,673,695\r\n9/12/2023\t270.76\t278.39\t266.6\t267.48\t135,999,906\r\n9/11/2023\t264.27\t274.85\t260.61\t273.58\t174,667,906\r\n9/8/2023\t251.22\t256.52\t246.67\t248.5\t118,559,602\r\n9/7/2023\t245.07\t252.81\t243.27\t251.49\t115,312,898\r\n9/6/2023\t255.14\t255.39\t245.06\t251.92\t116,959,797\r\n9/5/2023\t245\t258\t244.86\t256.49\t129,469,602\r\n9/1/2023\t257.26\t259.08\t242.01\t245.01\t132,541,594\r\n8/31/2023\t255.98\t261.18\t255.05\t258.08\t108,861,695\r\n8/30/2023\t254.2\t260.51\t250.59\t256.9\t121,988,398\r\n8/29/2023\t238.58\t257.48\t237.77\t257.18\t134,047,594\r\n8/28/2023\t242.58\t244.38\t235.35\t238.82\t107,673,695\r\n8/25/2023\t231.31\t239\t230.35\t238.59\t106,612,203\r\n8/24/2023\t238.66\t238.92\t228.18\t230.04\t99,777,430\r\n8/23/2023\t229.34\t238.98\t229.29\t236.86\t101,077,602\r\n8/22/2023\t240.25\t240.82\t229.55\t233.19\t130,597,906\r\n8/21/2023\t221.55\t232.13\t220.58\t231.28\t135,702,703\r\n8/18/2023\t214.12\t217.58\t212.36\t215.49\t136,276,609\r\n8/17/2023\t226.06\t226.74\t218.83\t219.22\t120,718,398\r\n8/16/2023\t228.02\t233.97\t225.38\t225.6\t112,484,492\r\n8/15/2023\t238.73\t240.5\t232.61\t232.96\t88,197,602\r\n8/14/2023\t235.7\t240.66\t233.75\t239.76\t98,595,328\r\n8/11/2023\t241.77\t243.79\t238.02\t242.65\t99,038,641\r\n8/10/2023\t245.4\t251.8\t243\t245.34\t109,498,602\r\n8/9/2023\t250.87\t251.1\t241.9\t242.19\t101,596,305\r\n8/8/2023\t247.45\t250.92\t245.01\t249.7\t96,642,180\r\n8/7/2023\t251.45\t253.65\t242.76\t251.45\t111,097,906\r\n8/4/2023\t260.97\t264.77\t253.11\t253.86\t99,539,914\r\n8/3/2023\t252.04\t260.49\t252\t259.32\t97,829,555\r\n8/2/2023\t255.57\t259.52\t250.49\t254.11\t101,752,898\r\n8/1/2023\t266.26\t266.47\t260.25\t261.07\t83,645,719\r\n7/31/2023\t267.48\t269.08\t263.78\t267.43\t84,582,172\r\n7/28/2023\t259.86\t267.25\t258.23\t266.44\t111,446,000\r\n7/27/2023\t268.31\t269.13\t255.3\t255.71\t103,697,297\r\n7/26/2023\t263.25\t268.04\t261.75\t264.35\t95,856,180\r\n7/25/2023\t272.38\t272.9\t265\t265.28\t112,757,297\r\n7/24/2023\t255.85\t269.85\t254.12\t269.06\t137,004,984\r\n7/21/2023\t268\t268\t255.8\t260.02\t161,796,094\r\n7/20/2023\t279.56\t280.93\t261.2\t262.9\t175,158,297\r\n7/19/2023\t296.04\t299.29\t289.52\t291.26\t142,355,391\r\n7/18/2023\t290.15\t295.26\t286.01\t293.34\t112,434,703\r\n7/17/2023\t286.63\t292.23\t283.57\t290.38\t131,569,594\r\n7/14/2023\t277.01\t285.3\t276.31\t281.38\t120,062,398\r\n7/13/2023\t274.59\t279.45\t270.6\t277.9\t112,681,508\r\n7/12/2023\t276.33\t276.52\t271.46\t271.99\t95,672,141\r\n7/11/2023\t268.65\t270.9\t266.37\t269.79\t91,972,359\r\n7/10/2023\t276.47\t277.52\t265.1\t269.61\t119,425,398\r\n7/7/2023\t278.43\t280.78\t273.77\t274.43\t113,879,203\r\n7/6/2023\t278.09\t279.97\t272.88\t276.54\t120,707,398\r\n7/5/2023\t278.82\t283.85\t277.6\t282.48\t131,530,891\r\n7/3/2023\t276.49\t284.25\t275.11\t279.82\t118,999,000\r\n6/30/2023\t260.6\t264.45\t259.89\t261.77\t112,620,797\r\n6/29/2023\t258.03\t260.74\t253.61\t257.5\t131,283,406\r\n6/28/2023\t249.7\t259.88\t248.89\t256.24\t159,770,797\r\n';
  late ChatSession _chat;
  late String _selectedDataSource;
  late String _selectedSeriesType;
  late AnimationController _controller;
  late Animation<double> _animation;

  List<_ChartData>? _chartData;
  List<_ChartData>? _aiGeneratedData;
  List<String>? _dataSorce;
  List<String>? _seriesType;

  bool _isAIGenerated = false;
  bool _isDisposed = false;
  bool _isRunning = false;
  bool _dataSourceChanged = false;
  bool _isButtonClicked = false;
  bool _isLoading = false;

  String _companyName = 'Microsoft Crp.';
  String _stockPrice = '152.82';
  int _autoscrollingDelta = 3;
  String _tooltipCompanyName = 'Microsoft Crp';

  late CartesianSeries<_ChartData, DateTime> _selectedSeries;
  ChartSeriesController<_ChartData, DateTime>? _chartSeriesController;

  @override
  void initState() {
    super.initState();

    // Initialize the animation controller
    _controller = AnimationController(
      duration: const Duration(seconds: 1),
      vsync: this,
    )..repeat(reverse: true); // Repeats the animation back and forth

    // Define the animation
    _animation = Tween<double>(
      begin: 0.8,
      end: 1.0,
    ).animate(CurvedAnimation(parent: _controller, curve: Curves.easeInOut));

    _dataSorce = <String>['MSFT', 'GOOG', 'AMZN', 'TSLA'].toList();
    _seriesType = <String>['Candle', 'OHLC', 'Line'].toList();
    _selectedDataSource = 'MSFT';
    _selectedSeriesType = 'Candle';

    _chartData = _generateCollection(msftStockSource);
    _selectedSeries = CandleSeries<_ChartData, DateTime>(
      dataSource: _chartData,
      xValueMapper: (_ChartData data, _) => data.date,
      lowValueMapper: (_ChartData data, _) => data.low,
      highValueMapper: (_ChartData data, _) => data.high,
      openValueMapper: (_ChartData data, _) => data.open,
      closeValueMapper: (_ChartData data, _) => data.close,
      animationDuration: 0,
      enableSolidCandles: true,
      onRendererCreated:
          (ChartSeriesController<_ChartData, DateTime> controller) {
            _chartSeriesController = controller;
          },
    );

    // Show the dialog when the app starts.
    WidgetsBinding.instance.addPostFrameCallback((_) {
      if (model.isFirstTime) {
        showDialog(
          context: context,
          builder: (context) => WelcomeDialog(
            primaryColor: model.primaryColor,
            apiKey: model.assistApiKey,
            onApiKeySaved: (newApiKey) {
              setState(() {
                model.assistApiKey = newApiKey;
              });
            },
          ),
        );
        model.isFirstTime = false;
      }
    });
  }

  Future<void> _addRangeWithDelayAsync(List<_ChartData> value) async {
    setState(() {
      _isLoading = false;
    });

    for (final _ChartData item in value) {
      if (_dataSourceChanged) {
        return;
      }

      if (_isDisposed) {
        break;
      }

      _chartData!.add(item);
      _chartSeriesController?.updateDataSource(
        addedDataIndexes: [_chartData!.length - 1],
      );

      await Future.delayed(const Duration(milliseconds: 300));
      if (_isDisposed) {
        break;
      }
    }
  }

  // Helper function to return the icon based on the selected value
  String _getIconForValue(String value) {
    switch (value) {
      case 'MSFT':
        return 'assets/microsoft.png';
      case 'GOOG':
        return 'assets/google.png';
      case 'AMZN':
        return 'assets/amazon.png';
      case 'TSLA':
        return 'assets/tesla.png';
      default:
        return 'assets/microsft.png'; // Default icon if no match
    }
  }

  @override
  Widget build(BuildContext context) {
    // Check if the device is mobile or web (based on screen width)
    final bool isMobile = MediaQuery.of(context).size.width < 600;

    // If it's a mobile device, execute the mobile-specific layout
    if (isMobile) {
      return _buildMobileLayout();
    } else {
      // If it's a web device (or larger screen), execute the web-specific layout
      return _buildWebLayout();
    }
  }

  Widget _buildMobileLayout() {
    return Container(
      padding: const EdgeInsets.fromLTRB(15, 10, 20, 10),
      child: Column(
        children: [
          Column(
            mainAxisAlignment: MainAxisAlignment.end,
            children: [
              Row(
                children: <Widget>[
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            _buildCompanyDataSource(),
                            Container(
                              alignment: Alignment.bottomRight,
                              child: const Text(
                                'AI-Powered Stock Forecasting',
                                style: TextStyle(fontSize: 15),
                              ),
                            ),
                          ],
                        ),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Row(
                                  mainAxisSize: MainAxisSize.min,
                                  children: [
                                    Column(
                                      crossAxisAlignment:
                                          CrossAxisAlignment.start,
                                      children: [
                                        Text(
                                          _companyName,
                                          style: const TextStyle(
                                            color: Colors.grey,
                                            fontSize: 12,
                                          ),
                                        ),
                                        Text(
                                          _stockPrice,
                                          style: const TextStyle(
                                            fontSize: 25,
                                            fontWeight: FontWeight.w400,
                                          ),
                                        ),
                                      ],
                                    ),
                                    const Padding(
                                      padding: EdgeInsets.fromLTRB(0, 22, 0, 0),
                                      child: Text(
                                        'USD',
                                        style: TextStyle(fontSize: 13),
                                      ),
                                    ),
                                    const Padding(
                                      padding: EdgeInsets.fromLTRB(5, 5, 0, 0),
                                      child: Column(
                                        mainAxisSize: MainAxisSize.min,
                                        crossAxisAlignment:
                                            CrossAxisAlignment.start,
                                        children: <Widget>[
                                          Text(
                                            'At Close',
                                            overflow: TextOverflow.clip,
                                            style: TextStyle(
                                              color: Colors.grey,
                                              fontSize: 12,
                                            ),
                                          ),
                                          Text(
                                            overflow: TextOverflow.clip,
                                            '-2.00(-0.22)',
                                            style: TextStyle(
                                              color: Colors.green,
                                              fontSize: 12,
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                  ],
                                ),
                              ],
                            ),
                            _buildAIButton(),
                          ],
                        ),
                      ],
                    ),
                  ),
                ],
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [_buildChartDuration(), _buildSeriesType()],
              ),
            ],
          ),
          _buildProgressIndicatorAndCartesianChart(),
        ],
      ),
    );
  }

  Widget _buildWebLayout() {
    return Container(
      padding: const EdgeInsets.fromLTRB(15, 10, 20, 10),
      child: Column(
        children: [
          Column(
            mainAxisAlignment: MainAxisAlignment.end,
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Expanded(
                    child: Column(
                      children: [
                        Row(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                _buildCompanyDataSource(),
                                Text(
                                  _companyName,
                                  style: const TextStyle(
                                    color: Colors.grey,
                                    fontSize: 14,
                                  ),
                                ),
                              ],
                            ),
                            _buildCompanyDetails(),
                          ],
                        ),
                      ],
                    ),
                  ),
                  Expanded(
                    child: Container(
                      padding: const EdgeInsets.fromLTRB(20, 5, 10, 0),
                      height: 50,
                      alignment: Alignment.topRight,
                      child: FittedBox(
                        fit: BoxFit.scaleDown,
                        child: ClipRect(
                          child: Text(
                            'AI-Powered Stock Forecasting',
                            style: TextStyle(
                              fontSize: MediaQuery.of(context).size.width > 600
                                  ? 25 // Dynamic scaling
                                  : 18, // Default font size for smaller screens
                            ),
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  _buildChartDuration(),
                  _buildSeriesType(),
                  _buildAIButton(),
                ],
              ),
            ],
          ),
          _buildProgressIndicatorAndCartesianChart(),
        ],
      ),
    );
  }

  Expanded _buildProgressIndicatorAndCartesianChart() {
    return Expanded(
      child: Stack(
        children: [
          _buildCartesianChart(),
          if (_isLoading) const Center(child: CircularProgressIndicator()),
        ],
      ),
    );
  }

  Widget _buildCompanyDataSource() {
    return Container(
      alignment: Alignment.bottomLeft,
      child: DropdownButton<String>(
        isDense: true,
        menuWidth: 110,
        dropdownColor: model.drawerBackgroundColor,
        borderRadius: BorderRadius.circular(8),
        focusColor: Colors.transparent,
        value: _selectedDataSource,
        underline: Container(height: 1),
        items: _dataSorce!.map((String value) {
          // Map each value to an image
          final String iconPath = _getIconForValue(value);
          return DropdownMenuItem<String>(
            value: value,
            child: Row(
              children: [
                Image.asset(iconPath, height: 20, width: 20),
                const SizedBox(width: 8),
                Text(value, style: TextStyle(color: model.textColor)),
              ],
            ),
          );
        }).toList(),
        onChanged: (dynamic value) {
          _onAxisRangeChange(value.toString());
        },
      ),
    );
  }

  Widget _buildChartDuration() {
    return Expanded(
      child: Row(
        children: [
          for (final item in [
            {'label': '3 Month', 'value': 3},
            {'label': '6 Month', 'value': 6},
            {'label': '1 Year', 'value': 12},
          ])
            TextButton(
              style: TextButton.styleFrom(
                backgroundColor: _autoscrollingDelta == item['value']
                    ? model.primaryColor.withValues(alpha: 0.2)
                    : null, // Default to white
                foregroundColor: _autoscrollingDelta == item['value']
                    ? model.primaryColor.withValues(alpha: 0.8)
                    : model.textColor.withValues(alpha: 0.7),
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(4),
                ),
              ),
              onPressed: () {
                setState(() {
                  _dataSourceChanged = true;
                  if (item['value'] != null) {
                    _autoscrollingDelta = item['value']! as int;
                  }
                });
              },
              child: Text(
                // ignore: cast_nullable_to_non_nullable
                item['label'] as String,
                style: const TextStyle(fontWeight: FontWeight.w700),
              ),
            ),
        ],
      ),
    );
  }

  Widget _buildCompanyDetails() {
    return Column(
      children: [
        Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            Container(
              padding: const EdgeInsets.fromLTRB(3, 12, 0, 0),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    _stockPrice,
                    style: const TextStyle(
                      fontSize: 25,
                      fontWeight: FontWeight.w400,
                    ),
                  ),
                ],
              ),
            ),
            const Padding(
              padding: EdgeInsets.fromLTRB(2, 20, 0, 0),
              child: Text('USD', style: TextStyle(fontSize: 13)),
            ),
            const Padding(
              padding: EdgeInsets.fromLTRB(5, 5, 0, 0),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    'At Close',
                    overflow: TextOverflow.clip,
                    style: TextStyle(color: Colors.grey, fontSize: 12),
                  ),
                  Text(
                    overflow: TextOverflow.clip,
                    '-2.00(-0.22)',
                    style: TextStyle(color: Colors.green, fontSize: 12),
                  ),
                ],
              ),
            ),
          ],
        ),
      ],
    );
  }

  Widget _buildSeriesType() {
    return Container(
      alignment: Alignment.bottomRight,
      decoration: BoxDecoration(
        border: Border.all(color: Colors.grey.shade200),
        borderRadius: BorderRadius.circular(5.0),
      ),
      child: DropdownButton<String>(
        isDense: true,
        menuWidth: 100,
        padding: const EdgeInsets.all(5),
        borderRadius: BorderRadius.circular(4),
        dropdownColor: model.drawerBackgroundColor,
        focusColor: Colors.transparent,
        underline: Container(height: 1),
        value: _selectedSeriesType,
        items: _seriesType!.map((String value) {
          return DropdownMenuItem<String>(
            value: (value != null) ? value : 'Candle',
            child: Text(value, style: TextStyle(color: model.textColor)),
          );
        }).toList(),
        onChanged: (dynamic value) {
          _onSeriesChange(value.toString());
        },
      ),
    );
  }

  Widget _buildAIButton() {
    return AnimatedBuilder(
      animation: _animation,
      builder: (BuildContext context, Widget? child) {
        return Container(
          padding: const EdgeInsets.fromLTRB(20, 0, 0, 5),
          alignment: Alignment.topCenter,
          child: Transform.scale(
            scale: _isButtonClicked ? 0.8 : _animation.value,
            child: FloatingActionButton(
              mini: true,
              backgroundColor: model.primaryColor,
              onPressed: _isRunning
                  ? null
                  : () {
                      _isButtonClicked = true;
                      _loadNewData();
                    },
              child: Image.asset(
                'images/ai_assist_view.png',
                height: 30,
                width: 40,
                color: Colors.white,
              ),
            ),
          ),
        );
      },
    );
  }

  Future<void> _loadNewData() async {
    _dataSourceChanged = false;

    setState(() {
      _isRunning = true;
      _isLoading = true;
      if (_isAIGenerated) {
        _chartData!.removeWhere(
          (element) => _aiGeneratedData!.contains(element),
        );
      }
    });

    if (model.assistApiKey.isNotEmpty) {
      final String prompt = _generatePrompt();
      await _sendChatMessage(prompt, model.assistApiKey);
    } else {
      final List<_ChartData> newDatas = _generateDataSource(_chartData!);

      await _addRangeWithDelayAsync(newDatas);
      _aiGeneratedData = newDatas;
      _isAIGenerated = true;
    }

    if (!mounted) {
      return;
    }

    setState(() {
      _isRunning = false;
    });
  }

  /// Return the Cartesian Chart with Line series.
  SfCartesianChart _buildCartesianChart() {
    return SfCartesianChart(
      plotAreaBorderWidth: 0,
      zoomPanBehavior: ZoomPanBehavior(
        enablePanning: true,
        zoomMode: ZoomMode.x,
      ),
      onTrackballPositionChanging: (TrackballArgs args) {
        args.chartPointInfo.label = _selectedSeriesType == 'Line'
            ? ' $_tooltipCompanyName: ${args.chartPointInfo.chartPoint!.y!.toStringAsFixed(2)}'
            : '$_tooltipCompanyName \nHigh: ${args.chartPointInfo.chartPoint!.high!.toStringAsFixed(2)} \nLow: ${args.chartPointInfo.chartPoint!.low!.toStringAsFixed(2)} \nOpen: ${args.chartPointInfo.chartPoint!.open!.toStringAsFixed(2)} \nClose: ${args.chartPointInfo.chartPoint!.close!.toStringAsFixed(2)}  ';
      },
      trackballBehavior: TrackballBehavior(
        enable: true,
        activationMode: ActivationMode.singleTap,
        tooltipDisplayMode: TrackballDisplayMode.groupAllPoints,
      ),
      primaryXAxis: DateTimeAxis(
        isVisible: Theme.of(context).platform == TargetPlatform.windows,
        interval: 0.5,
        intervalType: DateTimeIntervalType.months,
        labelStyle: const TextStyle(fontSize: 12.49),
        majorGridLines: const MajorGridLines(width: 0),
        dateFormat: DateFormat('MMM dd'),
        autoScrollingDelta: _autoscrollingDelta,
        plotBands: <PlotBand>[
          PlotBand(
            start: DateTime(2024, 6, 29),
            color: Theme.of(context).brightness == Brightness.light
                ? const Color.fromRGBO(231, 224, 236, 0.4)
                : const Color.fromRGBO(54, 50, 59, 0.4),
          ),
        ],
      ),
      primaryYAxis: const NumericAxis(
        interval: 20,
        majorTickLines: MajorTickLines(width: 0),
        axisLine: AxisLine(width: 0),
        rangePadding: ChartRangePadding.round,
      ),
      series: _buildCartesianSeries(),
    );
  }

  /// Returns the list of Cartesian Line series.
  List<CartesianSeries<_ChartData, DateTime>> _buildCartesianSeries() {
    return <CartesianSeries<_ChartData, DateTime>>[_selectedSeries];
  }

  void _onSeriesChange(String seriesType) {
    setState(() {
      _selectedSeriesType = seriesType; // Update the selected series type
      _updateSelectedSeries();
    });
  }

  /// Method for range padding change.
  void _onAxisRangeChange(String item) {
    setState(() {
      _isRunning = false;
      _selectedDataSource = item;
      switch (_selectedDataSource) {
        case 'MSFT':
          _chartData = _generateCollection(msftStockSource);
          _companyName = 'Microsoft Crp.';
          _stockPrice = '152.82';
          _dataSourceChanged = true;
          _tooltipCompanyName = 'Microsoft Crp';
          break;
        case 'GOOG':
          _chartData = _generateCollection(googleStackSource);
          _companyName = 'Alphabet Inc.';
          _stockPrice = '152.77';
          _dataSourceChanged = true;
          _tooltipCompanyName = 'Alphabet Inc';
          break;
        case 'AMZN':
          _chartData = _generateCollection(amznStackSource);
          _companyName = 'Amazon Inc.';
          _stockPrice = '152.64';
          _dataSourceChanged = true;
          _tooltipCompanyName = 'Amazon Inc';
          break;
        case 'TSLA':
          _chartData = _generateCollection(teslaStackSource);
          _companyName = 'Tesla Inc.';
          _stockPrice = '151.58';
          _dataSourceChanged = true;
          _tooltipCompanyName = 'Tesla Inc';
          break;
      }
      _updateSelectedSeries();
    });
  }

  void _updateSelectedSeries() {
    switch (_selectedSeriesType) {
      case 'OHLC':
        _selectedSeries = HiloOpenCloseSeries<_ChartData, DateTime>(
          dataSource: _chartData,
          xValueMapper: (_ChartData data, _) => data.date,
          lowValueMapper: (_ChartData data, _) => data.low,
          highValueMapper: (_ChartData data, _) => data.high,
          openValueMapper: (_ChartData data, _) => data.open,
          closeValueMapper: (_ChartData data, _) => data.close,
          animationDuration: 0,
          onRendererCreated:
              (ChartSeriesController<_ChartData, DateTime> controller) {
                _chartSeriesController = controller;
              },
        );
        break;
      case 'Candle':
        _selectedSeries = CandleSeries<_ChartData, DateTime>(
          dataSource: _chartData,
          xValueMapper: (_ChartData data, _) => data.date,
          lowValueMapper: (_ChartData data, _) => data.low,
          highValueMapper: (_ChartData data, _) => data.high,
          openValueMapper: (_ChartData data, _) => data.open,
          closeValueMapper: (_ChartData data, _) => data.close,
          animationDuration: 0,
          enableSolidCandles: true,
          onRendererCreated:
              (ChartSeriesController<_ChartData, DateTime> controller) {
                _chartSeriesController = controller;
              },
        );
        break;
      case 'Line':
        _selectedSeries = LineSeries<_ChartData, DateTime>(
          dataSource: _chartData,
          xValueMapper: (_ChartData data, _) => data.date,
          yValueMapper: (_ChartData data, _) => data.close,
          animationDuration: 0,
          onRendererCreated:
              (ChartSeriesController<_ChartData, DateTime> controller) {
                _chartSeriesController = controller;
              },
        );
        break;
    }
  }

  String _generatePrompt() {
    final List<_ChartData> items = [];

    final int length = _chartData!.length - 1;
    for (int i = length; i >= length - 50; i--) {
      items.add(_chartData![i]);
    }

    String prompt =
        'Generate 35 time steps candlestick data points using the provided historical data. '
        'Each candlestick should mimic realistic fluctuations, alternating between uptrends (close > open) and downtrends (close < open). '
        'Do not generate data with a continuous increase or decrease in values. Follow the trends, variability, and range of the provided historical data.\n\n'
        'Historical data (date:high:low:open:close):\n';
    for (final data in items) {
      prompt +=
          '${data.date}: ${data.high}, ${data.low}, ${data.open}, ${data.close}\n';
    }

    prompt +=
        'Rules for generated data:\n'
        '- Alternate between uptrend and downtrend candlesticks.\n'
        '- High > open and High > close.\n'
        '- Low < open and Low < close.\n'
        '- Maintain variability; do not generate overly smooth trends.\n'
        '- Occupy the range observed in the historical data while introducing variability.\n'
        '- Follow the trends and variability seen in the provided data.\n'
        '- Include date gaps (skip weekends).\n\n'
        'Output only the new candlestick data in the format: yyyy-MM-dd:High:Low:Open:Close. '
        'Do not include explanations, headers, or any additional text.\n';
    return prompt;
  }

  List<_ChartData> _convertAIResponseToChartData(String? data) {
    if (data == null || data.isEmpty) {
      return [];
    }

    final List<String> lines = LineSplitter.split(data).toList();
    final List<_ChartData> stockData = [];
    double high;
    double low;
    double open;
    double close;

    for (final String line in lines) {
      if (line.trim().isEmpty) {
        continue;
      }

      final List<String> parts = line.split(':');
      if (parts.length == 5) {
        try {
          final DateTime date = DateTime.parse(parts[0].trim());
          high = double.parse(parts[1].trim());
          low = double.parse(parts[2].trim());
          open = double.parse(parts[3].trim());
          close = double.parse(parts[4].trim());

          stockData.add(_ChartData(date, high, low, open, close));
        } catch (e) {
          // Handle any parse exceptions
        }
      }
    }

    return stockData;
  }

  Future<void> _sendChatMessage(String message, String apiKey) async {
    try {
      final model = GenerativeModel(
        model: 'gemini-1.5-flash-latest',
        apiKey: apiKey,
      );
      _chat = model.startChat();

      final GenerateContentResponse response = await _chat.sendMessage(
        Content.text(message),
      );

      final List<_ChartData> newDatas = _convertAIResponseToChartData(
        response.text,
      );

      await _addRangeWithDelayAsync(newDatas);
      _aiGeneratedData = newDatas;
      _isAIGenerated = true;
    } catch (e) {
      setState(() {
        _isLoading = false;
      });
    } finally {
      // Handle finally
    }
  }

  // Method to send the message and process AI response.
  List<_ChartData> _generateCollection(String dataSource) {
    final List<String> alphabetRows = dataSource
        .split(RegExp(r'[\r\n]+'))
        .where((row) => row.isNotEmpty)
        .toList();
    final List<_ChartData> alphabetCollection = [];

    for (final String row in alphabetRows) {
      final List<String> columns = row.split('\t');
      final _ChartData item = _ChartData(
        _parseDate(columns[0]),
        double.parse(columns[2]),
        double.parse(columns[3]),
        double.parse(columns[1]),
        double.parse(columns[4]),
      );
      alphabetCollection.add(item);
    }

    return alphabetCollection.reversed.toList();
  }

  DateTime _parseDate(String dateString) {
    final List<String> parts = dateString.split('/');
    final int month = int.parse(parts[0]);
    final int day = int.parse(parts[1]);
    final int year = int.parse(parts[2]);
    return DateTime(year, month, day);
  }

  List<_ChartData> _generateDataSource(List<_ChartData> stockData) {
    final List<_ChartData> items = [];
    final Random random = Random();

    // Find the last date in the stock data
    final DateTime lastDate = stockData[stockData.length - 1].date;
    DateTime nextDay = lastDate.add(const Duration(days: 1));

    // Get the close value of the last data as the starting open value
    double? initialOpen = stockData
        .firstWhere((data) => data.date == lastDate)
        .close;

    // Generate 45 new data points
    for (int i = 1; i <= 45; i++) {
      final DateTime date = nextDay;
      final open = initialOpen! + (random.nextDouble() - 0.5) * 30;
      final high = open + (random.nextDouble() * 2 - 1) * 10;
      final low = open - (random.nextDouble() * 2 - 1) * 10;
      final close = low + random.nextDouble() * (high - low);
      initialOpen = close; // Update for the next day's open value
      items.add(_ChartData(date, high, low, open, close));
      nextDay = date.add(const Duration(days: 1));
    }

    return items;
  }

  @override
  void dispose() {
    _chartData?.clear();
    _dataSorce?.clear();
    _seriesType?.clear();
    _controller.dispose();
    _aiGeneratedData?.clear();

    _isLoading = false;
    _isRunning = false;
    _isDisposed = true;
    _isAIGenerated = false;
    _isButtonClicked = false;
    _dataSourceChanged = false;
    super.dispose();
  }
}

class _ChartData {
  _ChartData(this.date, this.high, this.low, this.open, this.close);
  final DateTime date;
  final double? high;
  final double? low;
  final double? open;
  final double? close;
}
